From 352d1540e023289ef813a125fc805e3322097f6b Mon Sep 17 00:00:00 2001 From: leandor Date: Sun, 6 Nov 2016 01:53:12 -0300 Subject: [PATCH] (#18) Added a fixture for accessing data files Added a new fixture for using data files on test cases that require generating/validating execution against 'model' data. --- tests/papi/test_lz4.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/papi/test_lz4.py b/tests/papi/test_lz4.py index 783cca6..43ab852 100644 --- a/tests/papi/test_lz4.py +++ b/tests/papi/test_lz4.py @@ -1,4 +1,23 @@ +from __future__ import unicode_literals +from distutils import dir_util from pytest import fixture +from os import path + + +@fixture +def datadir(tmpdir, request): + ''' + Fixture responsible for searching a folder with the same name of test + module and, if available, moving all contents to a temporary directory so + tests can use them freely. + ''' + filename = request.module.__file__ + test_dir, _ = path.splitext(filename) + + if path.isdir(test_dir): + dir_util.copy_tree(test_dir, bytes(tmpdir)) + + return tmpdir @fixture def lz4():