コード例 #1
0
    def create_file(dirname):
        def default_env_specs_func():
            return [
                EnvSpec(
                    name='abc',
                    conda_packages=['anaconda'],
                    pip_packages=[],
                    channels=['mychannel'],
                    description="ABC",
                    inherit_from_names=(),
                    inherit_from=()),
                EnvSpec(
                    name='xyz',
                    conda_packages=['foo'],
                    pip_packages=[],
                    channels=['bar'],
                    description="XYZ",
                    inherit_from_names=(),
                    inherit_from=())
            ]

        filename = os.path.join(dirname, DEFAULT_PROJECT_FILENAME)
        assert not os.path.exists(filename)
        project_file = ProjectFile.load_for_directory(dirname, default_env_specs_func=default_env_specs_func)
        assert project_file is not None
        assert not os.path.exists(filename)
        project_file.save()
        assert os.path.exists(filename)
        with codecs.open(filename, 'r', 'utf-8') as file:
            contents = file.read()
            expected = expected_two_env_spec_contents.replace("<NAME>", os.path.basename(dirname))
            assert_identical_except_blank_lines(expected, contents)
コード例 #2
0
 def create_file(dirname):
     filename = os.path.join(dirname, DEFAULT_PROJECT_FILENAME)
     assert not os.path.exists(filename)
     project_file = ProjectFile.load_for_directory(dirname)
     assert project_file is not None
     assert not os.path.exists(filename)
     project_file.save()
     assert os.path.exists(filename)
     with codecs.open(filename, 'r', 'utf-8') as file:
         contents = file.read()
         expected = expected_default_file.replace("<NAME>", os.path.basename(dirname))
         assert_identical_except_blank_lines(expected, contents)
コード例 #3
0
    def create_file(dirname):
        filename = os.path.join(dirname, DEFAULT_PROJECT_LOCK_FILENAME)
        assert not os.path.exists(filename)
        lock_file = ProjectLockFile.load_for_directory(dirname)
        assert lock_file is not None
        assert not os.path.exists(filename)

        assert _get_lock_set(lock_file, 'foo').disabled
        assert not _get_locking_enabled(lock_file, 'foo')

        lock_file.save()
        # should not have saved an unmodified (default) file)
        assert not os.path.exists(filename)

        # make a change, which should cause us to save
        lock_file.set_value(['something'], 42)

        lock_file.save()
        assert os.path.exists(filename)
        with codecs.open(filename, 'r', 'utf-8') as file:
            contents = file.read()
            expected = expected_default_file + "something: 42\n"
            assert_identical_except_blank_lines(expected, contents)