[pypy-svn] buildbot default: turn the getfiles tests over to generate_tests

RonnyPfannschmidt commits-noreply at bitbucket.org
Wed Apr 20 15:53:24 CEST 2011


Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: 
Changeset: r460:9ea95b60e126
Date: 2011-04-19 08:50 +0200
http://bitbucket.org/pypy/buildbot/changeset/9ea95b60e126/

Log:	turn the getfiles tests over to generate_tests

diff --git a/bitbucket_hook/test/test_irc.py b/bitbucket_hook/test/test_irc.py
--- a/bitbucket_hook/test/test_irc.py
+++ b/bitbucket_hook/test/test_irc.py
@@ -3,8 +3,8 @@
 def fl(*paths):
     return [{'file': x} for x in paths]
 
-def test_getpaths():
-    d = dict
+def pytest_generate_tests(metafunc):
+
     barefile = fl('file')
     distinct = fl('path1/file1', 'path2/file2', 'path3/file')
     shared = fl('path/file1', 'path/file2', 'path/file')
@@ -22,9 +22,9 @@
                 'some/path/to/anotherfile', 'some/path/to/afile')
     commonplusroot = shared + barefile
 
-    empty = d(file='')
-    nocommonplusempty = distinct + [empty]
-    commonplusempty = shared + [empty]
+    empty = fl('')
+    nocommonplusempty = distinct + empty
+    commonplusempty = shared + empty
     nocommonplusslash = distinct + fl('path4/dir/')
     commonplusslash = shared + fl('path/dir/')
 
@@ -32,59 +32,51 @@
                          'pypy/jit/metainterp/test/test_c.py',
                          'pypy/jit/metainterp/test/test_o.py')
 
-    pypyempty = fl('pypy/rlib/rdtoa.py', 'pypy/rlib/test/test_rdtoa.py'
+    pypyempty = fl('pypy/rlib/rdtoa.py', 'pypy/rlib/test/test_rdtoa.py')
+
 
     nothing = ('', '')
+    expectations = [
+        ('null', [], nothing),
+        ('empty', empty, nothing),
+        ('empty*2', empty*2, nothing),
+        ('bare', barefile, ('file', '')),
+        ('deep', deepfile, ('a/long/path/to/deepfile.py', '')),
+        ('slashes', slashesfile, ('/slashesfile/', '')),
+        ('slashleft', slashleft, ('/slashleft', '')),
+        ('slashright', slashright, ('slashright/', '')),
+        ('nocommon', nocommon, ('', ' M(file1, file2, file, file)')),
+        ('nocommon+root', nocommonplusroot, 
+                          ('', ' M(file1, file2, file, file)')),
+        ('nocommon+empty', nocommonplusempty, ('',' M(file1, file2, file)')),
+        ('common', common, ('some/path/to/',
+                ' M(file, file, anotherfile, afile)')),
+        ('common+root', commonplusroot, ('', ' M(file1, file2, file, file)')),
+        ('common+empty', commonplusempty, ('',' M(file1, file2, file)')),
+        ('nocommon+slash', nocommonplusslash, ('',' M(file1, file2, file)')),
+        ('common+slash', commonplusslash, ('path/',' M(file1, file2, file)')),
+        ('pypydoubledash', pypydoubleslash, ('pypy/jit/metainterp/',
+                         ' M(u.py, test_c.py, test_o.py)')),
+        ('pypyempty', pypyempty, ('pypy/rlib/',
+                   ' M(rdtoa.py, test_rdtoa.py)')),
+        ]
 
-    # (input, expected output) for listfiles=False
-    files_expected = [([], nothing),
-                      ([empty], nothing),
-                      ([empty, empty], nothing),
-                      (barefile, ('file', '')),
-                      (deepfile, ('a/long/path/to/deepfile.py', '')),
-                      (slashesfile, ('/slashesfile/', '')),
-                      (slashleft, ('/slashleft', '')),
-                      (slashright, ('slashright/', '')),
-                      (nocommon, nothing),
-                      (nocommonplusroot, nothing),
-                      (nocommonplusempty, nothing),
-                      (common, ('some/path/to/', '')),
-                      (commonplusroot, nothing),
-                      (commonplusempty, nothing),
-                      (nocommonplusslash, nothing),
-                      (commonplusslash, ('path/', '')),
-                      (pypydoubleslash, ('pypy/jit/metainterp/', '')),
-                      (pypyempty, ('pypy/rlib/', '')),
-                      ]
+    for name, files, (common, listfiles) in expectations:
+        metafunc.addcall(id='list/'+name, funcargs={
+            'files': files,
+            'expected_common': common,
+            'expected_listfiles': listfiles,
+        })
+        metafunc.addcall(id='nolist/'+name, funcargs={
+            'files': files,
+            'expected_common': common,
+            'expected_listfiles': listfiles,
+        })
 
-    for f, wanted in files_expected:
-        assert getpaths(f) == wanted
 
-    # (input, expected output) for listfiles=True
-    files_expected = [([], nothing),
-                      ([empty], nothing),
-                      ([empty, empty], nothing),
-                      (barefile, ('file', '')),
-                      (deepfile, ('a/long/path/to/deepfile.py', '')),
-                      (slashesfile, ('/slashesfile/', '')),
-                      (slashleft, ('/slashleft', '')),
-                      (slashright, ('slashright/', '')),
-                      (nocommon, ('', ' M(file1, file2, file, file)')),
-                      (nocommonplusroot, ('', ' M(file1, file2, file, file)')),
-                      (nocommonplusempty, ('',' M(file1, file2, file)')),
-                      (common, ('some/path/to/',
-                                ' M(file, file, anotherfile, afile)')),
-                      (commonplusroot, ('', ' M(file1, file2, file, file)')),
-                      (commonplusempty, ('',' M(file1, file2, file)')),
-                      (nocommonplusslash, ('',' M(file1, file2, file)')),
-                      (commonplusslash, ('path/',' M(file1, file2, file)')),
-                      (pypydoubleslash, ('pypy/jit/metainterp/',
-                                         ' M(u.py, test_c.py, test_o.py)')),
-                      (pypyempty, ('pypy/rlib/',
-                                   ' M(rdtoa.py, test_rdtoa.py)')),
-                      ]
+def test_getpaths(files, expected_common, expected_listfiles):
+    common, files = getpaths(files, listfiles=bool(expected_listfiles))
+    assert common == expected_common
+    assert files == expected_listfiles
 
-    for f, wanted in files_expected:
-        assert getpaths(f, listfiles=True) == wanted
 
-


More information about the Pypy-commit mailing list