def testConstructor(self): t = NamedTemporaryFile() h = InputHistory() h = InputHistory(t.name) h = InputHistory(t.name, 'foo') h.set('aaa', 'bbb') self.assertEqual(open(t.name).read(), '[foo]\naaa = bbb\n\n') # Will fail on Windows platform. See notes for setUp method.
def testConstructor(self): t = NamedTemporaryFile() h = InputHistory() h = InputHistory(t.name) h = InputHistory(t.name, 'foo') h.set('aaa', 'bbb') self.assertEqual(open(t.name).read(), '[foo]\naaa = bbb\n\n')
class InputHistoryTest(unittest.TestCase): CORRELATE = InputHistory def setUp(self): t = NamedTemporaryFile() # Flawed on Windows platform because of exclusive open mode. Should use ``next(tempfile._get_candidate_names())`` for getting just file name. self.history = InputHistory(t.name) def testConstructor(self): t = NamedTemporaryFile() h = InputHistory() h = InputHistory(t.name) h = InputHistory(t.name, 'foo') h.set('aaa', 'bbb') self.assertEqual(open(t.name).read(), '[foo]\naaa = bbb\n\n') # Will fail on Windows platform. See notes for setUp method. def testGet(self): self.assertEqual(self.history.get('bar'), None) self.assertEqual(self.history.get('bar', None), None) self.assertEqual(self.history.get('bar', '...'), '...') self.history.set('bar', 'myvalue') self.assertEqual(self.history.get('bar'), 'myvalue') self.assertEqual(self.history.get('bar', '...'), 'myvalue') self.assertEqual(self.history.get('bar', None), 'myvalue') def testSet(self): self.testGet() self.history.set('bar', 'myvalue2') self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2') self.history.set('bar', None) self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2')
def setUp(self): t = NamedTemporaryFile() # Flawed on Windows platform because of exclusive open mode. Should use ``next(tempfile._get_candidate_names())`` for getting just file name. self.history = InputHistory(t.name)
def setUp(self): t = NamedTemporaryFile() self.history = InputHistory(t.name)
class InputHistoryTest(unittest.TestCase): CORRELATE = InputHistory def setUp(self): t = NamedTemporaryFile() self.history = InputHistory(t.name) def testConstructor(self): t = NamedTemporaryFile() h = InputHistory() h = InputHistory(t.name) h = InputHistory(t.name, 'foo') h.set('aaa', 'bbb') with open(t.name) as fp: self.assertEqual(fp.read(), '[foo]\naaa = bbb\n\n') def testGet(self): self.assertEqual(self.history.get('bar'), None) self.assertEqual(self.history.get('bar', None), None) self.assertEqual(self.history.get('bar', '...'), '...') self.history.set('bar', 'myvalue') self.assertEqual(self.history.get('bar'), 'myvalue') self.assertEqual(self.history.get('bar', '...'), 'myvalue') self.assertEqual(self.history.get('bar', None), 'myvalue') def testSet(self): self.testGet() self.history.set('bar', 'myvalue2') self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2') self.history.set('bar', None) self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2')
class InputHistoryTest(unittest.TestCase): CORRELATE = InputHistory def setUp(self): t = NamedTemporaryFile() self.history = InputHistory(t.name) def testConstructor(self): t = NamedTemporaryFile() h = InputHistory() h = InputHistory(t.name) h = InputHistory(t.name, 'foo') h.set('aaa', 'bbb') self.assertEqual(open(t.name).read(), '[foo]\naaa = bbb\n\n') def testGet(self): self.assertEqual(self.history.get('bar'), None) self.assertEqual(self.history.get('bar', None), None) self.assertEqual(self.history.get('bar', '...'), '...') self.history.set('bar', 'myvalue') self.assertEqual(self.history.get('bar'), 'myvalue') self.assertEqual(self.history.get('bar', '...'), 'myvalue') self.assertEqual(self.history.get('bar', None), 'myvalue') def testSet(self): self.testGet() self.history.set('bar', 'myvalue2') self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2') self.history.set('bar', None) self.assertEqual(self.history.get('bar'), 'myvalue2') self.assertEqual(self.history.get('bar', '...'), 'myvalue2') self.assertEqual(self.history.get('bar', None), 'myvalue2')