mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-05-02 12:44:46 +00:00
Added equal operator to values.Value
Allows value setting to work when checking if setting variable is within a list, i.e: settings.database in ['default', 'other']
This commit is contained in:
parent
c60b7daac4
commit
c6bd78e6b8
2 changed files with 7 additions and 0 deletions
|
|
@ -75,6 +75,9 @@ class Value(object):
|
|||
def __repr__(self):
|
||||
return repr(self.value)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.value == other
|
||||
|
||||
def setup(self, name):
|
||||
value = self.default
|
||||
if self.environ:
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ class ValueTests(TestCase):
|
|||
self.assertEqual(value1.setup('TEST1'), 'override1')
|
||||
self.assertEqual(value2.setup('TEST2'), 'override2')
|
||||
|
||||
def test_value_var_in_list(self):
|
||||
value = Value('default')
|
||||
self.assertTrue(value in ['default'])
|
||||
|
||||
def test_env_var_prefix(self):
|
||||
with patch.dict(os.environ, clear=True, ACME_TEST='override'):
|
||||
value = Value('default', environ_prefix='ACME')
|
||||
|
|
|
|||
Loading…
Reference in a new issue