Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.config = confuse.Configuration('test', read=False)
def test_search_package(self):
config = confuse.Configuration('myapp', __name__, read=False)
config._add_default_source()
for source in config.sources:
if source.default:
default_source = source
break
else:
self.fail("no default source")
self.assertEqual(
default_source.filename,
os.path.join(os.path.dirname(__file__), 'config_default.yaml')
)
self.assertTrue(source.default)
def test_dump_short_list(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': ['bar', 'baz']})
yaml = config.dump().strip()
self.assertEqual(yaml, 'foo: [bar, baz]')
def test_dump_unredacted(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': 'bar'})
config['foo'].redact = True
yaml = config.dump(redact=False).strip()
self.assertEqual(yaml, 'foo: bar')
def test_dump_null(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': None})
yaml = config.dump().strip()
self.assertEqual(yaml, 'foo:')
def test_dump_sans_defaults(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': 'bar'})
config.sources[0].default = True
config.add({'baz': 'qux'})
yaml = config.dump().strip()
self.assertEqual(yaml, "foo: bar\nbaz: qux")
yaml = config.dump(full=False).strip()
self.assertEqual(yaml, "baz: qux")
def test_dump_redacted_sans_defaults(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': 'bar'})
config.sources[0].default = True
config.add({'baz': 'qux'})
config['baz'].redact = True
yaml = config.dump(redact=True, full=False).strip()
self.assertEqual(yaml, "baz: REDACTED")
def test_dump_redacted(self):
config = confuse.Configuration('myapp', read=False)
config.add({'foo': 'bar'})
config['foo'].redact = True
yaml = config.dump(redact=True).strip()
self.assertEqual(yaml, 'foo: REDACTED')
def __init__(self):
"""The config constructor should be called only once."""
if self.config is None:
self.config = confuse.Configuration("PandasProfiling", __name__)
self.config.set_file(str(get_config_default()))