def test_partial_messages_with_windows_line_endings():
    frontend = FakeFrontend()

    frontend.partial_info("a\r\nb\r\nc\r\nd")
    # d is stuck in the buffer
    assert frontend.logs == ['a', 'b', 'c']
    assert frontend._info_buf == 'd'
Example #2
0
    def check(dirname):
        frontend = FakeFrontend()
        patterns = archiver._parse_ignore_file(os.path.join(dirname, ".projectignore"), frontend)
        assert [] == frontend.errors

        pattern_strings = [pattern.pattern for pattern in patterns]

        assert pattern_strings == []
Example #3
0
    def check(dirname):
        frontend = FakeFrontend()
        patterns = archiver._parse_ignore_file(os.path.join(dirname, ".projectignore"), frontend)
        assert [] == frontend.errors

        pattern_strings = [pattern.pattern for pattern in patterns]

        assert pattern_strings == ['bar', '/baz', 'whitespace_surrounding',
                                   'foo # this comment will be part of the pattern', '#patternwithhash', 'hello']
Example #4
0
    def check(dirname):
        project_ops._add_projectignore_if_none(dirname)
        ignorefile = os.path.join(dirname, ".projectignore")
        assert os.path.isfile(ignorefile)

        frontend = FakeFrontend()
        patterns = archiver._parse_ignore_file(ignorefile, frontend)
        assert [] == frontend.errors

        pattern_strings = [pattern.pattern for pattern in patterns]

        assert pattern_strings == ['/anaconda-project-local.yml', '__pycache__/', '*.pyc', '*.pyo', '*.pyd',
                                   '/.ipynb_checkpoints', '/.spyderproject']
Example #5
0
def project_no_dedicated_env(*args, **kwargs):
    """Get a project that won't create envs/default as long as there's an env already."""
    if len(args) > 0:
        dirname = args[0]
    elif 'directory_path' in kwargs:
        dirname = kwargs['directory_path']
    else:
        raise RuntimeError("no directory_path for Project")

    project_dir_disable_dedicated_env(dirname)

    if 'frontend' not in kwargs:
        kwargs['frontend'] = FakeFrontend()

    project = Project(*args, **kwargs)

    return project
Example #6
0
    def check(dirname):
        frontend = FakeFrontend()
        ignorefile = os.path.join(dirname, ".projectignore")

        from codecs import open as real_open

        def mock_codecs_open(*args, **kwargs):
            if args[0].endswith(".projectignore"):
                raise IOError("NOPE")
            else:
                return real_open(*args, **kwargs)

        monkeypatch.setattr('codecs.open', mock_codecs_open)

        patterns = archiver._parse_ignore_file(ignorefile, frontend)
        assert patterns is None
        assert ["Failed to read %s: NOPE" % ignorefile] == frontend.errors

        # enable cleaning it up
        os.chmod(ignorefile, 0o777)
def test_partial_messages():
    frontend = FakeFrontend()

    frontend.partial_info("a\nb\nc\nd")
    # d is stuck in the buffer
    assert frontend.logs == ['a', 'b', 'c']
    assert frontend._info_buf == 'd'

    frontend.partial_error("1")
    frontend.partial_error("2")
    frontend.partial_error("3")
    frontend.partial_error("456")
    assert frontend._error_buf == "123456"
    frontend.partial_error("\n")

    assert frontend._error_buf == ""
    assert frontend.errors == ['123456']

    frontend.partial_error("\n\n\n\n")
    assert frontend.errors == ['123456', '', '', '', '']