Exemplo n.º 1
0
 def testAmbg2(self):
     # Note: as described in Issue #5 (https://github.com/jeffreystarr/dateinfer/issues/5), the
     # result should be %d/%m/%Y as the more likely choice. However, at this point, we will
     # allow %m/%d/%Y.
     self.assertIn(
         infer(['04/12/2012', '05/12/2012', '06/12/2012', '07/12/2012']),
         ['%d/%m/%Y', '%m/%d/%Y'])
Exemplo n.º 2
0
        def testFormat(self):
            # verify initial conditions
            self.assertTrue(hasattr(self, 'test_data'),
                            'testdata field not set on test object')

            expected = self.test_data['format']
            actual = infer(self.test_data['examples'])

            self.assertEqual(
                expected, actual,
                '{0}: Inferred `{1}`!=`{2}`'.format(self.test_data['name'],
                                                    actual, expected))
Exemplo n.º 3
0
        def testFormat(self):
            # verify initial conditions
            self.assertTrue(hasattr(self, 'test_data'),
                            'testdata field not set on test object')

            expected = self.test_data['format']
            testcase_locale = self.test_data.get('locale', 'en_US.UTF-8')

            with setlocale(testcase_locale):
                actual = infer(self.test_data['examples'])

            error_fmt = '{0}: Inferred `{1}`!=`{2}`'

            self.assertEqual(
                expected, actual,
                error_fmt.format(self.test_data['name'], actual, expected))
Exemplo n.º 4
0
 def testAmbg1(self):
     self.assertIn(infer(['1/1/2012']), ['%m/%d/%Y', '%d/%m/%Y'])