def test_imports_with_import_error_caught_the_other_way(self): self.assertFalse( main.warnings_for_string("""\ try: from configparser import RawConfigParser except ImportError: from ConfigParser import RawConfigParser """))
def _test_code(self, name, casename=None): warnings = main.warnings_for_string(globals()['code_' + name], name) if not casename: casename = 'Fix' + name.title() self.assertTrue(len(warnings)) self.assertTrue(casename in warnings[0][1]) return warnings
def test_ignore_compatible_raw_input(self): self.assertFalse( main.warnings_for_string('raw_input = input\nraw_input()\n'))
def test_raw_input(self): self.assertTrue(main.warnings_for_string('raw_input()\n'))
def test_ignore_compatible_zip(self): self.assertFalse( main.warnings_for_string('enumerate(zip([1, 2], [3, 4]))\n'))
def test_zip(self): self.assertTrue(main.warnings_for_string('zip([1, 2], [3, 4])\n'))
def test_ignore_compatible_long(self): self.assertFalse(main.warnings_for_string('long = int\nlong\n'))
def test_ignore_compatible_unichr(self): self.assertFalse(main.warnings_for_string('unichr = chr\nunichr(1)\n'))
def test_print_with_parentheses(self): self.assertFalse(main.warnings_for_string('print("%d" % 3)\n'))
def test_imports(self): self.assertTrue( main.warnings_for_string("""\ from ConfigParser import RawConfigParser """))
def test_print(self): self.assertTrue(main.warnings_for_string('print 3\n'))
def test_xrange(self): self.assertTrue(main.warnings_for_string('xrange(3)\n'))
def test_ignore_compatible_basestring(self): self.assertFalse( main.warnings_for_string('basestring = str\nbasestring\n'))
def test_do_not_crash_on_unicode(self): main.warnings_for_string('u"å"')
def test_long(self): self.assertTrue(main.warnings_for_string('long\n'))
def test_ignore_compatible_unicode(self): self.assertFalse( main.warnings_for_string('unicode = str\nunicode("abc")\n'))
def test_unichr(self): self.assertTrue(main.warnings_for_string('unichr(1)\n'))