<commit_before>import os
import pytest
from atomicio.api import atomic_write, transform


@pytest.fixture
def path(tmpdir):
    return tmpdir.join('something')


@pytest.mark.parametrize('exist', [True, False])
def test_atomic_write(path, exist):
    if exist:
        path.write('')

    with atomic_write(str(path)) as (r,w):
        w.write('haha')

    assert path.read() == 'haha'


def test_atomic_write_with_reading(path):
    path.write('ha')

    with atomic_write(str(path)) as (r,w):
        for item in r:
            w.write(item)
            w.write(item)

    assert path.read() == 'haha'


def test_transform(path):
    path.write('ha')

    def func(r):
        for item in r:
            yield item
            yield item

    transform(str(path), func)
    assert path.read() == 'haha'<commit_msg>modularize fixtures<commit_after>import os
import pytest
from atomicio.api import atomic_write, transform


@pytest.fixture
def path(tmpdir):
    return tmpdir.join('something')


@pytest.mark.parametrize('exist', [True, False])
def test_atomic_write(path, exist):
    if exist:
        path.write('')

    with atomic_write(str(path)) as (r,w):
        w.write('haha')

    assert path.read() == 'haha'


@pytest.fixture
def existent_path(path):
    path.write('ha')
    return path


def test_atomic_write_with_reading(existent_path):
    with atomic_write(str(existent_path)) as (r,w):
        for item in r:
            w.write(item)
            w.write(item)
    assert existent_path.read() == 'haha'


def test_transform(existent_path):
    def func(r):
        for item in r:
            yield item
            yield item

    transform(str(existent_path), func)
    assert existent_path.read() == 'haha'
{'fraction_non_alphanumeric': 0.12738853503184713, 'fraction_numerical': 0.0, 'mean_word_length': 2.9006772009029347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5586063', 'n_tokens_mistral': 594, 'n_tokens_neox': 575, 'n_words': 134}