def test_odd_input(self): input = iter(['test.com', 'test data', 'foo.org', 'foo data', 'bar.net']) result = {url: data for (url, data) in vanity.by_two(input)} self.assertEqual(result['test.com'], 'test data') self.assertEqual(result['foo.org'], 'foo data') self.assertIsNone(result.get('bar.net'))
def test_pairs_url_and_data(self): input = iter(['test.com', 'test data', 'foo.org', 'foo data', 'bar.net', 'bar data']) result = {url: data for (url, data) in vanity.by_two(input)} self.assertEqual(result['test.com'], 'test data') self.assertEqual(result['foo.org'], 'foo data') self.assertEqual(result['bar.net'], 'bar data')
def test_none(self): input = iter(()) result = {url: data for (url, data) in vanity.by_two(input)} self.assertEqual(result, {})