def test_create_instance_with_invalid_configs(self): with self.subTest("with no local storage"): with self.assertRaises(InvalidConfigError): config = TestConfig() config.LOCAL_STORAGE_LOCATION = '' FileSystemStorage(config) with self.subTest("with a relative path"): with self.assertRaises(InvalidConfigError): config = TestConfig() config.LOCAL_STORAGE_LOCATION = '../../etc' FileSystemStorage(config) with self.subTest("with None config"): with self.assertRaises(InvalidConfigError): FileSystemStorage(None) with self.subTest("with valid config"): config = TestConfig() storage = FileSystemStorage(config) from decouple import config BASE_DIR = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '/test') self.assertEqual(storage.config.LOCAL_STORAGE_LOCATION, config('LOCAL_STORAGE_LOCATION'))