implicit loading of sibling directory's

Create issue
Issue #109 resolved
Former user created an issue

As discussed on the mailing list (subject: funcarg name clash / conftest load behaviour) it would be nice if py.test does not implicitely load the sibling directory's in case those directories are not packaged with an

Consider the directory structure:

ROOTDIR/ a/ b/

Calling py.test from ROOTDIR with argument 'a' (or from ROOTDIR/a without args) should not load b/

The applied patch against py-1.3.1 adds a test case for this situation. I have to say that I'm not sure whether the location is best and things in it might be done better, because this was the fist time I'm in touch with the code.

Best regards, Frank

Comments (6)

  1. Former user Account Deleted
    diff -aur py-1.3.1/testing/ py-1.3.1-first-non-init-containing-dir-test/testing/
    --- py-1.3.1/testing/	2010-05-25 20:16:40.000000000 +0200
    +++ py-1.3.1-first-non-init-containing-dir-test/testing/	2010-06-27 13:41:45.000000000 +0200
    @@ -221,7 +221,28 @@
             col = config.getnode(x)
             trail = config._rootcol.totrail(col)
             col2 = config._rootcol.fromtrail(trail)
    -        assert col2 == col 
    +        assert col2 == col
    +    def test_first_non_init_containing_dir(self, testdir):
    +        for dirname in ('a', 'b'):
    +            testdir.tmpdir.ensure(dirname, dir=True)
    +            testdir.tmpdir.ensure(dirname, '')
    +            # To create the I would like to use testdir.make*-methods
    +            # but as far as I have seen they can only create files in testdir.tempdir
    +            backupTmpDir = testdir.tmpdir
    +            testdir.tmpdir = testdir.tmpdir.join(dirname)
    +            testdir.makeconftest("""
    +                _DIR_NAME = '%s'
    +                def pytest_configure(config):
    +                    if config.args and config.args[0] != _DIR_NAME:
    +                        raise Exception("py.test run for '" + config.args[0] + "', but '" + _DIR_NAME + "/' loaded.")
    +            """ % dirname)
    +            testdir.tmpdir = backupTmpDir
    +        for dirname, other_dirname in (('a', 'b'), ('b', 'a')):
    +            result = testdir.runpytest(dirname)
    +            assert result.ret == 0, "test_first_non_init_containing_dir: py.test run for '%s', but '%s/' loaded." % (dirname, other_dirname)
         def test_totrail_topdir_and_beyond(self, testdir, tmpdir):
             config = testdir.reparseconfig()
  2. struppimoppi

    Please ignore the patch from the last anonymous comment. Now I managed to sign up to bitbucket and am able to attach files... :) I reviewed the patch so the attached file will work for py-1.3.2 and I added a little more comments too.

    Best Regards, Frank

  3. Bluebird

    Is there any way to disable the sibling directory looking ? I read the discussion on the ML and I entirely agree with Frank. Test behavior should not depend on side directories. I may have up to 6 or 7 checkout of the same project in one directory. Running py.test in one of them runs it in all of them !

  4. Log in to comment