-from django.test import TestCase
-
+import pytest
import pyflakes.api
import os
-class PyflakesTest(TestCase):
- def setUp(self):
+class Test_Pyflakes(object):
+ @pytest.fixture
+ def pyfiles(self):
topdir = os.path.dirname(os.path.realpath(__file__))
- self.pythonfiles = []
+ pythonfiles = []
for folder, subfolders, files in os.walk(topdir):
if 'migrations' in subfolders:
for file in files:
if not file.endswith('.py'):
continue
- self.pythonfiles += [os.path.join(folder, file)]
+ pythonfiles += [os.path.join(folder, file)]
+ return pythonfiles
- def test_pyflakes(self):
- for file in self.pythonfiles:
- self.assertEqual(pyflakes.api.checkPath(file), 0)
+ def test_pyflakes(self, pyfiles):
+ for file in pyfiles:
+ assert pyflakes.api.checkPath(file) == 0