<commit_before>import py
import pytest

from _pytest.tmpdir import tmpdir, TempdirFactory

def test_funcarg(testdir):
    testdir.makepyfile("""
            def pytest_generate_tests(metafunc):
                metafunc.addcall(id='a')
                metafunc.addcall(id='b')
            def test_func(tmpdir): pass
    """)
    reprec = testdir.inline_run()
    calls = reprec.getcalls("pytest_runtest_setup")
    item = calls[0].item
    config = item.config
    tmpdirhandler = TempdirFactory(config)
    item._initrequest()
    p = tmpdir(item._request, tmpdirhandler)
    assert p.check()
    bn = p.basename.strip("0123456789")
    assert bn.endswith("test_func_a_")
    item.name = "qwe/\\abc"
    p = tmpdir(item._request, tmpdirhandler)
    assert p.check()
    bn = p.basename.strip("0123456789")
    assert bn == "qwe__abc"

def test_ensuretemp(recwarn):
    #pytest.deprecated_call(pytest.ensuretemp, 'hello')
    d1 = pytest.ensuretemp('hello')
    d2 = pytest.ensuretemp('hello')
    assert d1 == d2
    assert d1.check(dir=1)

class TestTempdirHandler:
    def test_mktemp(self, testdir):
        config = testdir.parseconfig()
        config.option.basetemp = testdir.mkdir("hello")
        t = TempdirFactory(config)
        tmp = t.mktemp("world")<commit_msg>Fix flakes<commit_after>import py
import pytest

from _pytest.tmpdir import tmpdir

def test_funcarg(testdir):
    testdir.makepyfile("""
            def pytest_generate_tests(metafunc):
                metafunc.addcall(id='a')
                metafunc.addcall(id='b')
            def test_func(tmpdir): pass
    """)
    from _pytest.tmpdir import TempdirFactory
    reprec = testdir.inline_run()
    calls = reprec.getcalls("pytest_runtest_setup")
    item = calls[0].item
    config = item.config
    tmpdirhandler = TempdirFactory(config)
    item._initrequest()
    p = tmpdir(item._request, tmpdirhandler)
    assert p.check()
    bn = p.basename.strip("0123456789")
    assert bn.endswith("test_func_a_")
    item.name = "qwe/\\abc"
    p = tmpdir(item._request, tmpdirhandler)
    assert p.check()
    bn = p.basename.strip("0123456789")
    assert bn == "qwe__abc"

def test_ensuretemp(recwarn):
    #pytest.deprecated_call(pytest.ensuretemp, 'hello')
    d1 = pytest.ensuretemp('hello')
    d2 = pytest.ensuretemp('hello')
    assert d1 == d2
    assert d1.check(dir=1)

class TestTempdirHandler:
    def test_mktemp(self, testdir):
        from _pytest.tmpdir import TempdirFactory
        config = testdir.parseconfig()
        config.option.basetemp = testdir.mkdir("hello")
        t = TempdirFactory(config)
        tmp = t.mktemp("world")
{'fraction_non_alphanumeric': 0.12048650703154694, 'fraction_numerical': 0.020524515393386546, 'mean_word_length': 3.0806201550387597, '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': '4296444', 'n_tokens_mistral': 925, 'n_tokens_neox': 905, 'n_words': 161}