-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #386 from adamchainz/pep_451
Move to PEP-451 style loader
- Loading branch information
Showing
6 changed files
with
104 additions
and
72 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
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,8 @@ | ||
from configurations import Configuration | ||
|
||
|
||
class ErrorConfiguration(Configuration): | ||
|
||
@classmethod | ||
def pre_setup(cls): | ||
raise ValueError("Error in pre_setup") |
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,22 @@ | ||
import os | ||
from django.test import TestCase | ||
from unittest.mock import patch | ||
|
||
|
||
class ErrorTests(TestCase): | ||
|
||
@patch.dict(os.environ, clear=True, | ||
DJANGO_CONFIGURATION='ErrorConfiguration', | ||
DJANGO_SETTINGS_MODULE='tests.settings.error') | ||
def test_env_loaded(self): | ||
with self.assertRaises(ValueError) as cm: | ||
from tests.settings import error # noqa: F401 | ||
|
||
self.assertIsInstance(cm.exception, ValueError) | ||
self.assertEqual( | ||
cm.exception.args, | ||
( | ||
"Couldn't setup configuration " | ||
"'tests.settings.error.ErrorConfiguration': Error in pre_setup ", | ||
) | ||
) |
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