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)
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)
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)
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)
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)
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)