def test_egg_info_data(file_contents, expected): om = mock_open(read_data=file_contents) em = Mock() em.return_value = 'cp1252' with patch('pip.utils.open', om, create=True): with patch('locale.getpreferredencoding', em): ret = read_text_file('foo') assert ret == expected.decode('utf-8')
def test_egg_info_data(file_contents, expected): om = mock_open(read_data=file_contents) em = Mock() em.return_value = "cp1252" with patch("pip.utils.open", om, create=True): with patch("locale.getpreferredencoding", em): ret = read_text_file("foo") assert ret == expected.decode("utf-8")
def egg_info_data(self, filename): if self.satisfied_by is not None: if not self.satisfied_by.has_metadata(filename): return None return self.satisfied_by.get_metadata(filename) assert self.source_dir filename = self.egg_info_path(filename) if not os.path.exists(filename): return None data = read_text_file(filename) return data