Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 03cf004

refactor how tests create the source packages they operate on

Comments (0)

Files changed (2)


     globals()['pytest_funcarg__' + name] = lambda request, name=name: getattr(request.getfuncargvalue('config'), name)
-def pytest_funcarg__fullsource(request):
-    source = request.getfuncargvalue('config').source
-    source.join('kij.yml').write(
-            'name: test\n'
-            'scripts: [foo, bin/bar]\n'
-            'packages: [testpkg]\n'
-            )
-    source.ensure('foo')
-    source.ensure('bin/bar')
-    source.ensure('testpkg/')
-    return source
 def pytest_funcarg__config(request):
     tmpdir = request.getfuncargvalue('tmpdir')
     for name, subdir in dirs.items():
         paths[name] = tmpdir.ensure(subdir, dir=1)
+    contents = getattr(request.function, 'has_source', None)
+    if contents is not None:
+        for name, content in contents.args[0].iteritems():
+            file = paths['source'].ensure(name)
+            file.write(content)
     return Config(paths)


+import py
 from import CopyPackagesToBuild, CompileByteCode, \
         CopyScripts, Build
 from kij.task_queue import Queue
+package_contents = {
+    'testpkg/': '',
+    'kij.yml': 'name: test\npackages: [testpkg]\n',
-def test_copy_build(source,config):
-    source.ensure('testpkg/')
-    source.join('kij.yml').write('name: test\npackages: [testpkg]\n')
+has_source = py.test.mark.has_source(package_contents)
+def test_copy_build(source, config):
     task = CopyPackagesToBuild(config)
     queue = Queue()
     assert config.build_lib.join('testpkg/').check()
 def test_build_and_compile(source, tmpdir, config, build_lib):
     queue = Queue()
-    source.ensure('testpkg/')
-    source.join('kij.yml').write('name: test\npackages: [testpkg]\n')
     compile = CompileByteCode(config)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.