# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <hol...@merlinux.eu>
# Date 1280759976 -7200
# Node ID 971cc7cb03bb49131642fb6ab06a7ca38a2f5094
# Parent  a62793ba63d19cbecfaaf5c1b94f04477fa0a8b2
committed a xfailing test for sibling conftests

--- a/testing/test_collect.py
+++ b/testing/test_collect.py
@@ -266,6 +266,35 @@ class TestRootCol:
         col2 = config._rootcol.fromtrail(trail)
         assert col2 == col
 
+    @py.test.mark.xfail(reason="http://bitbucket.org/hpk42/py-trunk/issue/109";)
+    def test_sibling_conftest_issue109(self, testdir):
+        """
+        This test is to make sure that the conftest.py of sibling directories 
is not loaded
+        if py.test is run for/in one of the siblings directory and those 
sibling directories
+        are not packaged together with an __init__.py. See bitbucket issue 
#109.
+        """
+        for dirname in ['a', 'b']:
+            testdir.tmpdir.ensure(dirname, dir=True)
+            testdir.tmpdir.ensure(dirname, '__init__.py')
+
+            # To create the conftest.py I would like to use 
testdir.make*-methods
+            # but as far as I have seen they can only create files in 
testdir.tempdir
+            # Maybe there is a way to explicitly specifiy the directory on 
which those
+            # methods work or a completely better way to do that?
+            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 + "/conftest.py' loaded.")
+            """ % dirname)
+            testdir.tmpdir = backupTmpDir
+
+        for dirname, other_dirname in [('a', 'b'), ('b', 'a')]:
+            result = testdir.runpytest(dirname)
+            assert result.ret == 0, "test_sibling_conftest: py.test run for 
'%s', but '%s/conftest.py' loaded." % (dirname, other_dirname)
+
     def test_totrail_topdir_and_beyond(self, testdir, tmpdir):
         config = testdir.reparseconfig()
         col = config.getnode(config.topdir)
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to