Exemple #1
0
 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.
Exemple #2
0
 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')
Exemple #3
0
 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')
Exemple #4
0
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')
Exemple #5
0
 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)
Exemple #6
0
 def setUp(self):
     t = NamedTemporaryFile()
     self.history = InputHistory(t.name)
Exemple #7
0
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')
Exemple #8
0
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')
Exemple #9
0
 def setUp(self):
     t = NamedTemporaryFile()
     self.history = InputHistory(t.name)