Skip to content

Commit

Permalink
Fixed issues with testing of PyPi packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikail KOCAK committed Sep 3, 2020
1 parent c7ca32f commit 7c22af7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from os import environ

environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
9 changes: 8 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import json
import os
import os.path
import shutil

import mock
import pytest
Expand Down Expand Up @@ -316,6 +319,7 @@ def test_xdist_combine_racecondition(testdir):
script = testdir.makepyfile(
test_module="""
import pytest
import sys
@pytest.mark.parametrize("foo", range(500))
@pytest.mark.count_queries
Expand All @@ -329,13 +333,16 @@ def test_foo(foo):
cursor.fetchone()"""
)

# Append current test files into the temporary test directory in order
# to have settings.py available for PyPi packages
shutil.copytree(os.path.dirname(__file__), os.path.join(str(testdir) + "/tests"))
results = testdir.runpytest("--django-db-bench", results_path, "-n", "5", script)

# Ensure the tests have passed
results.assert_outcomes(500, 0, 0)
assert results_path.check()

# Check the resulst
# Check the results
results = json.load(results_path)
assert list(results.keys()) == ["test_module"]
assert len(results["test_module"]) == 500

0 comments on commit 7c22af7

Please sign in to comment.