Commits

holger krekel  committed a4c7bbb

remove config.getinitialnodes() method that was only used for testing method after the refactoring.

  • Participants
  • Parent commits 2a855c3

Comments (0)

Files changed (5)

File py/_plugin/pytest_python.py

 def showfuncargs(config):
     from py._test.session import Collection
     collection = Collection(config)
-    colitem = collection.getinitialnodes()[0]
+    firstid = collection._normalizearg(config.args[0])
+    colitem = collection.getbyid(firstid)[0]
     curdir = py.path.local()
     tw = py.io.TerminalWriter()
     plugins = getplugins(colitem, withpy=True)

File py/_test/session.py

             matching = l
         return matching
 
-    def getinitialnodes(self):
-        idlist = [self._normalizearg(arg) for arg in self.config.args]
-        nodes = []
-        for id in idlist:
-            nodes.extend(self.getbyid(id))
-        return nodes
-
     def perform_collect(self):
         nodes = []
         for arg in self.config.args:

File testing/plugin/test_pytest_python.py

                     pass
        """
 
+def test_show_funcarg(testdir):
+    result = testdir.runpytest("--funcargs")
+    result.stdout.fnmatch_lines([
+            "*tmpdir*",
+            "*temporary directory*",
+        ]
+    )

File testing/plugin/test_pytest_terminal.py

     ])
     assert result.ret == 0
 
-def test_show_funcarg(testdir, option):
-    args = option.args + ["--funcargs"]
-    result = testdir.runpytest(*args)
-    result.stdout.fnmatch_lines([
-            "*tmpdir*",
-            "*temporary directory*",
-        ]
-    )
 
 class TestGenericReporting:
     """ this test class can be subclassed with a different option

File testing/test_collection.py

         assert gettopdir(["%s::xyc::abc" % c]) == a
         assert gettopdir(["%s::xyc" % c, "%s::abc" % Z]) == tmp
 
+def getargnode(collection, arg):
+    return collection.getbyid(collection._normalizearg(str(arg)))[0]
+
 class Test_getinitialnodes:
     def test_onedir(self, testdir):
         config = testdir.reparseconfig([testdir.tmpdir])
-        colitems = Collection(config).getinitialnodes()
-        assert len(colitems) == 1
-        col = colitems[0]
+        c = Collection(config)
+        col = getargnode(c, testdir.tmpdir)
         assert isinstance(col, py.test.collect.Directory)
         for col in col.listchain():
             assert col.config is config
-
-    def test_twodirs(self, testdir, tmpdir):
-        config = testdir.reparseconfig([tmpdir, tmpdir])
-        colitems = Collection(config).getinitialnodes()
-        assert len(colitems) == 2
-        col1, col2 = colitems
-        assert col1.name == col2.name
-        assert col1.parent == col2.parent
+        t2 = getargnode(c, testdir.tmpdir)
+        assert col == t2
 
     def test_curdir_and_subdir(self, testdir, tmpdir):
         a = tmpdir.ensure("a", dir=1)
         config = testdir.reparseconfig([tmpdir, a])
-        colitems = Collection(config).getinitialnodes()
-        assert len(colitems) == 2
-        col1, col2 = colitems
+        c = Collection(config)
+        
+        col1 = getargnode(c, tmpdir)
+        col2 = getargnode(c, a)
         assert col1.name == tmpdir.basename
         assert col2.name == 'a'
-        for col in colitems:
+        for col in (col1, col2):
             for subcol in col.listchain():
                 assert col.config is config
 
     def test_global_file(self, testdir, tmpdir):
         x = tmpdir.ensure("x.py")
         config = testdir.reparseconfig([x])
-        col, = Collection(config).getinitialnodes()
+        col = getargnode(Collection(config), x)
         assert isinstance(col, py.test.collect.Module)
         assert col.name == 'x.py'
         assert col.parent.name == tmpdir.basename
     def test_global_dir(self, testdir, tmpdir):
         x = tmpdir.ensure("a", dir=1)
         config = testdir.reparseconfig([x])
-        col, = Collection(config).getinitialnodes()
+        col = getargnode(Collection(config), x)
         assert isinstance(col, py.test.collect.Directory)
         print(col.listchain())
         assert col.name == 'a'
         x = tmpdir.ensure("x.py")
         tmpdir.ensure("__init__.py")
         config = testdir.reparseconfig([x])
-        col, = Collection(config).getinitialnodes()
+        col = getargnode(Collection(config), x)
         assert isinstance(col, py.test.collect.Module)
         assert col.name == 'x.py'
         assert col.parent.name == x.dirpath().basename