Ejemplo n.º 1
0
 def test_bytes_kwargs(self):
     txt = utils.log_pprint(kwargs={'x': b'\xe1\xe2', 'y': b'\xe2\xe1'})
     expected1 = "x=b'\\xe1\\xe2', y=b'\\xe2\\xe1'"
     expected2 = "y=b'\\xe2\\xe1', x=b'\\xe1\\xe2'"
     if is_python2:
         expected1 = expected1.replace('b', '')
         expected2 = expected2.replace('b', '')
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 2
0
 def test_text_kwargs(self):
     txt = utils.log_pprint(kwargs={'x': 'ŧêßŧ', 'y': 'ŧßêŧ'})
     expected1 = "x='ŧêßŧ', y='ŧßêŧ'"
     expected2 = "y='ŧßêŧ', x='ŧêßŧ'"
     if is_python2:
         expected1 = "x=u'\\u0167\\xea\\xdf\\u0167', y=u'\\u0167\\xdf\\xea\\u0167'"
         expected2 = "y=u'\\u0167\\xdf\\xea\\u0167', x=u'\\u0167\\xea\\xdf\\u0167'"
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 3
0
 def test_bytes_kwargs(self):
     txt = str(utils.log_pprint(kwargs={
         'x': b'\xe1\xe2',
         'y': b'\xe2\xe1'
     }))
     expected1 = "x=b'\\xe1\\xe2', y=b'\\xe2\\xe1'"
     expected2 = "y=b'\\xe2\\xe1', x=b'\\xe1\\xe2'"
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 4
0
 def test_text_kwargs(self):
     txt = str(utils.log_pprint(kwargs={'x': 'ŧêßŧ', 'y': 'ŧßêŧ'}))
     expected1 = "x='ŧêßŧ', y='ŧßêŧ'"
     expected2 = "y='ŧßêŧ', x='ŧêßŧ'"
     if is_python2:
         expected1 = "x=u'\\u0167\\xea\\xdf\\u0167', y=u'\\u0167\\xdf\\xea\\u0167'"
         expected2 = "y=u'\\u0167\\xdf\\xea\\u0167', x=u'\\u0167\\xea\\xdf\\u0167'"
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 5
0
 def test_bytes_kwargs(self):
     txt = str(utils.log_pprint(kwargs={'x': b'\xe1\xe2', 'y': b'\xe2\xe1'}))
     expected1 = "x=b'\\xe1\\xe2', y=b'\\xe2\\xe1'"
     expected2 = "y=b'\\xe2\\xe1', x=b'\\xe1\\xe2'"
     if is_python2:
         expected1 = expected1.replace('b', '')
         expected2 = expected2.replace('b', '')
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 6
0
    def test_unicode_repr(self):
        class UnicodeRepr(object):
            def __repr__(self):
                return 'hello'

        txt = utils.log_pprint([UnicodeRepr()])
        # currently should cause an error in Python 2
        if is_python2:
            expected_type = 'str'
        else:
            expected_type = 'unicode'
        self.assertEquals(type(txt), expected_type)
Ejemplo n.º 7
0
    def generate(self, step, params):
        if not params:
            return None

        subfactory = step.builder.factory_meta.factory
        logger.debug(
            "ParentNodeFactory: Instantiating %s.%s(%s), create=%r",
            subfactory.__module__,
            subfactory.__name__,
            utils.log_pprint(kwargs=params),
            step,
        )
        force_sequence = step.sequence if self.FORCE_SEQUENCE else None
        return step.recurse(subfactory, params, force_sequence=force_sequence)
Ejemplo n.º 8
0
 def test_text_kwargs(self):
     txt = str(utils.log_pprint(kwargs={'x': 'ŧêßŧ', 'y': 'ŧßêŧ'}))
     expected1 = "x='ŧêßŧ', y='ŧßêŧ'"
     expected2 = "y='ŧßêŧ', x='ŧêßŧ'"
     self.assertIn(txt, (expected1, expected2))
Ejemplo n.º 9
0
 def test_bytes_args(self):
     txt = str(utils.log_pprint((b'\xe1\xe2', )))
     expected = "b'\\xe1\\xe2'"
     self.assertEqual(expected, txt)
Ejemplo n.º 10
0
 def test_text_args(self):
     txt = utils.log_pprint(('ŧêßŧ', ))
     expected = "'ŧêßŧ'"
     if is_python2:
         expected = "u'\\u0167\\xea\\xdf\\u0167'"
     self.assertEqual(expected, txt)
Ejemplo n.º 11
0
 def test_nothing(self):
     txt = str(utils.log_pprint())
     self.assertEqual('', txt)
Ejemplo n.º 12
0
 def test_only_kwargs(self):
     txt = utils.log_pprint(kwargs={'a': 1, 'b': 2})
     self.assertIn(txt, ['a=1, b=2', 'b=2, a=1'])
Ejemplo n.º 13
0
 def test_bytes_args(self):
     txt = utils.log_pprint((b'\xe1\xe2', ))
     expected = "b'\\xe1\\xe2'"
     if is_python2:
         expected = expected.lstrip('b')
     self.assertEqual(expected, txt)
Ejemplo n.º 14
0
 def test_nothing(self):
     txt = utils.log_pprint()
     self.assertEqual('', txt)
Ejemplo n.º 15
0
 def test_only_args(self):
     txt = utils.log_pprint((1, 2, 3))
     self.assertEqual('1, 2, 3', txt)
Ejemplo n.º 16
0
 def test_only_args(self):
     txt = str(utils.log_pprint((1, 2, 3)))
     self.assertEqual('1, 2, 3', txt)
Ejemplo n.º 17
0
 def test_text_args(self):
     txt = str(utils.log_pprint(('ŧêßŧ', )))
     expected = "'ŧêßŧ'"
     self.assertEqual(expected, txt)
Ejemplo n.º 18
0
 def test_text_args(self):
     txt = str(utils.log_pprint(('ŧêßŧ',)))
     expected = "'ŧêßŧ'"
     if is_python2:
         expected = "u'\\u0167\\xea\\xdf\\u0167'"
     self.assertEqual(expected, txt)
Ejemplo n.º 19
0
 def test_bytes_args(self):
     txt = str(utils.log_pprint((b'\xe1\xe2',)))
     expected = "b'\\xe1\\xe2'"
     if is_python2:
         expected = expected.lstrip('b')
     self.assertEqual(expected, txt)
Ejemplo n.º 20
0
 def test_only_kwargs(self):
     txt = str(utils.log_pprint(kwargs={'a': 1, 'b': 2}))
     self.assertIn(txt, ['a=1, b=2', 'b=2, a=1'])