コード例 #1
0
ファイル: test_cache.py プロジェクト: pwmarcz/pip-tools
def test_read_cache_file_wrong_format():
    """
    A cache file with a wrong "__format__" value should throw an assertion error.
    """
    with _read_cache_file_helper('{"__format__": 2}') as cache_file_name:
        with raises(AssertionError):
            read_cache_file(cache_file_name)
コード例 #2
0
ファイル: test_cache.py プロジェクト: sebadima/pip-tools
def test_read_cache_file_wrong_format():
    """
    A cache file with a wrong "__format__" value should throw an assertion error.
    """
    with _read_cache_file_helper('{"__format__": 2}') as cache_file_name:
        with pytest.raises(ValueError, match=r"^Unknown cache file format$"):
            read_cache_file(cache_file_name)
コード例 #3
0
ファイル: test_cache.py プロジェクト: pwmarcz/pip-tools
def test_read_cache_file_not_json():
    """
    A cache file that's not JSON should throw a corrupt cache error.
    """
    with _read_cache_file_helper("not json") as cache_file_name:
        with raises(CorruptCacheError):
            read_cache_file(cache_file_name)
コード例 #4
0
ファイル: test_cache.py プロジェクト: GuyHoozdis/pip-tools
def test_read_cache_file_wrong_format():
    """
    A cache file with a wrong "__format__" value should throw an assertion error.
    """
    with _read_cache_file_helper('{"__format__": 2}') as cache_file_name:
        with raises(AssertionError):
            read_cache_file(cache_file_name)
コード例 #5
0
ファイル: test_cache.py プロジェクト: GuyHoozdis/pip-tools
def test_read_cache_file_not_json():
    """
    A cache file that's not JSON should throw a corrupt cache error.
    """
    with _read_cache_file_helper("not json") as cache_file_name:
        with raises(CorruptCacheError):
            read_cache_file(cache_file_name)
コード例 #6
0
ファイル: test_cache.py プロジェクト: sebadima/pip-tools
def test_read_cache_file_not_json():
    """
    A cache file that's not JSON should throw a corrupt cache error.
    """
    with _read_cache_file_helper("not json") as cache_file_name:
        with pytest.raises(
                CorruptCacheError,
                match="The dependency cache seems to have been corrupted.",
        ):
            read_cache_file(cache_file_name)
コード例 #7
0
ファイル: test_cache.py プロジェクト: sebadima/pip-tools
def test_read_cache_file_successful():
    """
    A good cache file.
    """
    with _read_cache_file_helper(
            '{"__format__": 1, "dependencies": "success"}') as cache_file_name:
        assert "success" == read_cache_file(cache_file_name)
コード例 #8
0
def test_read_cache_file_successful():
    """
    A good cache file.
    """
    with _read_cache_file_helper(
        '{"__format__": 1, "dependencies": "success"}'
    ) as cache_file_name:
        assert "success" == read_cache_file(cache_file_name)