def test_write_writes_new_content_to_path(self): s = Source() tf = tempfile.NamedTemporaryFile() s.get_updated_contents = lambda: 'abc\ndef' s.path = tf.name s.write() with open(tf.name) as f: self.assertEqual(f.read(), s.get_updated_contents())