diff --git a/AUTHORS b/AUTHORS index cc4aaa6ad..717c19b2e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -161,6 +161,7 @@ Stefan Zimmermann Stefano Taschini Steffen Allner Stephan Obermann +Tarcisio Fischer Tareq Alayan Ted Xiao Thomas Grainger diff --git a/_pytest/pytester.py b/_pytest/pytester.py index fc9b8d9cb..573640014 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -412,16 +412,8 @@ class Testdir: def __init__(self, request, tmpdir_factory): self.request = request self._mod_collections = WeakKeyDictionary() - # XXX remove duplication with tmpdir plugin - basetmp = tmpdir_factory.ensuretemp("testdir") name = request.function.__name__ - for i in range(100): - try: - tmpdir = basetmp.mkdir(name + str(i)) - except py.error.EEXIST: - continue - break - self.tmpdir = tmpdir + self.tmpdir = tmpdir_factory.mktemp(name, numbered=True) self.plugins = [] self._savesyspath = (list(sys.path), list(sys.meta_path)) self._savemodulekeys = set(sys.modules) diff --git a/changelog/2751.bugfix b/changelog/2751.bugfix new file mode 100644 index 000000000..76004a653 --- /dev/null +++ b/changelog/2751.bugfix @@ -0,0 +1 @@ +``testdir`` now uses use the same method used by ``tmpdir`` to create its temporary directory. This changes the final structure of the ``testdir`` directory slightly, but should not affect usage in normal scenarios and avoids a number of potential problems. \ No newline at end of file diff --git a/testing/test_collection.py b/testing/test_collection.py index 5d1654410..ab0c93bae 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -569,7 +569,6 @@ class Test_getinitialnodes(object): col = testdir.getnode(config, x) assert isinstance(col, pytest.Module) assert col.name == 'x.py' - assert col.parent.name == testdir.tmpdir.basename assert col.parent.parent is None for col in col.listchain(): assert col.config is config