Преглед изворни кода

filename is not optional

While it can be set to ultimately a value of None, when a
config file is read in from stdin, it is not optional.

We kinda make use of it's ability to be set to None in our
tests but functionally and design wise, it is required.

If filename is not set, extends does not work.

Signed-off-by: Mazz Mosley <[email protected]>
Mazz Mosley пре 10 година
родитељ
комит
1344533b24
3 измењених фајлова са 4 додато и 4 уклоњено
  1. 1 1
      compose/config/config.py
  2. 1 1
      tests/integration/testcases.py
  3. 2 2
      tests/unit/config_test.py

+ 1 - 1
compose/config/config.py

@@ -151,7 +151,7 @@ def load(config_details):
 
 
 class ServiceLoader(object):
-    def __init__(self, working_dir, filename=None, already_seen=None):
+    def __init__(self, working_dir, filename, already_seen=None):
         if working_dir is None:
             raise Exception("No working_dir passed to ServiceLoader()")
 

+ 1 - 1
tests/integration/testcases.py

@@ -31,7 +31,7 @@ class DockerClientTestCase(unittest.TestCase):
         if 'command' not in kwargs:
             kwargs['command'] = ["top"]
 
-        options = ServiceLoader(working_dir='.').make_service_dict(name, kwargs)
+        options = ServiceLoader(working_dir='.', filename=None).make_service_dict(name, kwargs)
 
         labels = options.setdefault('labels', {})
         labels['com.docker.compose.test-name'] = self.id()

+ 2 - 2
tests/unit/config_test.py

@@ -11,11 +11,11 @@ from compose.config import config
 from compose.config.errors import ConfigurationError
 
 
-def make_service_dict(name, service_dict, working_dir):
+def make_service_dict(name, service_dict, working_dir, filename=None):
     """
     Test helper function to construct a ServiceLoader
     """
-    return config.ServiceLoader(working_dir=working_dir).make_service_dict(name, service_dict)
+    return config.ServiceLoader(working_dir=working_dir, filename=filename).make_service_dict(name, service_dict)
 
 
 def service_sort(services):