From 5e759c53a9e9d484b41364dc911d0583162d2434 Mon Sep 17 00:00:00 2001 From: Fenn-25 Date: Tue, 10 Jul 2018 18:23:18 +0100 Subject: [PATCH] installed pytest dependency,added runner Signed-off-by: Fenn-25 --- .gitignore | 1 + infohub/runner.py | 29 +++++++++++++++++++++++++++++ pytest.ini | 2 ++ requirements.txt | 8 ++++++++ 4 files changed, 40 insertions(+) create mode 100644 infohub/runner.py create mode 100644 pytest.ini diff --git a/.gitignore b/.gitignore index 43980989..eca87ca9 100755 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ submit/ *.DS_Store */migrations/ credentials.json +.pytest_cache \ No newline at end of file diff --git a/infohub/runner.py b/infohub/runner.py new file mode 100644 index 00000000..98cb7d4a --- /dev/null +++ b/infohub/runner.py @@ -0,0 +1,29 @@ +class PytestTestRunner(object): + """Runs pytest to discover and run tests.""" + + def __init__(self, verbosity=1, failfast=False, keepdb=False, **kwargs): + self.verbosity = verbosity + self.failfast = failfast + self.keepdb = keepdb + + def run_tests(self, test_labels): + """Run pytest and return the exitcode. + + It translates some of Django's test command option to pytest's. + """ + import pytest + + argv = [] + if self.verbosity == 0: + argv.append('--quiet') + if self.verbosity == 2: + argv.append('--verbose') + if self.verbosity == 3: + argv.append('-vv') + if self.failfast: + argv.append('--exitfirst') + if self.keepdb: + argv.append('--reuse-db') + + argv.extend(test_labels) + return pytest.main(argv) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..fb568e78 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = infohub.settings \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ecee76c5..d4ce663a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,3 +36,11 @@ six==1.11.0 social-auth-app-django==2.1.0 social-auth-core==1.6.0 static3==0.7.0 +pytest==3.5.1 +mock==2.0.0 +pytest-selenium==1.10.0 +pytest-django==3.1.2 +selenium==3.4.3 +pytest-variables==1.6.1 +pytest-base-url==1.3.0 +pytest-metadata==1.7.0