-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d585b8
commit f8183c3
Showing
11 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
|
||
from django.test.runner import DebugSQLTextTestResult, DiscoverRunner | ||
|
||
from pdbr.__main__ import RichPdb, post_mortem | ||
|
||
|
||
class PDBRDebugResult(unittest.TextTestResult): | ||
_pdbr = RichPdb() | ||
|
||
def addError(self, test, err): | ||
super().addError(test, err) | ||
self._print(test, err) | ||
|
||
def addFailure(self, test, err): | ||
super().addFailure(test, err) | ||
self._print(test, err) | ||
|
||
def _print(self, test, err): | ||
self.buffer = False | ||
self._pdbr.message(f"\n{test}") | ||
self._pdbr.error(f"{err[0].__name__}: {err[1]}") | ||
post_mortem(err[2]) | ||
|
||
|
||
class PdbrDiscoverRunner(DiscoverRunner): | ||
def get_resultclass(self): | ||
if self.debug_sql: | ||
return DebugSQLTextTestResult | ||
return PDBRDebugResult |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
import sys | ||
|
||
import django | ||
from django.conf import settings | ||
from django.test.utils import get_runner | ||
|
||
if __name__ == "__main__": | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.tests_django.test_settings' | ||
django.setup() | ||
TestRunner = get_runner(settings) | ||
test_runner = TestRunner() | ||
failures = test_runner.run_tests(["tests"]) | ||
sys.exit(bool(failures)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
|
||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
SECRET_KEY = "fake-key" | ||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"), | ||
} | ||
} | ||
|
||
TEST_RUNNER = "pdbr.runner.PdbrDiscoverRunner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.test import TestCase | ||
|
||
|
||
class DjangoTest(TestCase): | ||
def test_runner(self): | ||
self.assertEqual("foo", "foo") |