def test_ignore_comments(self): sys.stdout = StringIO() try: similar.run(["--ignore-comments", SIMILAR1, SIMILAR2]) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertMultiLineEqual( output.strip(), ( """ 7 similar lines in 2 files ==%s:5 ==%s:5 same file as this one. more than 4 identical lines should be detected TOTAL lines=38 duplicates=7 percent=18.42 """ % (SIMILAR1, SIMILAR2) ).strip(), )
def test_no_args(self): sys.stdout = StringIO() try: try: similar.run([]) except SystemExit, ex: self.assertEquals(ex.code, 1) else:
def test_help(self): sys.stdout = StringIO() try: try: similar.run(['--help']) except SystemExit, ex: self.assertEquals(ex.code, 0) else:
def test_no_args(self): sys.stdout = StringIO() try: try: similar.run([]) except SystemExit, ex: self.assertEqual(ex.code, 1) else:
def test_help(self): sys.stdout = StringIO() try: try: similar.run(['--help']) except SystemExit, ex: self.assertEqual(ex.code, 0) else:
def test_dont_ignore_comments(self): sys.stdout = StringIO() try: similar.run([SIMILAR1, SIMILAR2]) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertMultiLineEqual( output.strip(), """ TOTAL lines=38 duplicates=0 percent=0.00 """.strip())
def test_dont_ignore_comments(self): sys.stdout = StringIO() try: similar.run([SIMILAR1, SIMILAR2]) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertMultiLineEqual( output.strip(), """ TOTAL lines=38 duplicates=0 percent=0.00 """.strip(), )
def test_ignore_comments(self): sys.stdout = StringIO() try: similar.run(['--ignore-comments', SIMILAR1, SIMILAR2]) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertMultiLineEqual(output.strip(), (""" 7 similar lines in 2 files ==%s:5 ==%s:5 same file as this one. more than 4 identical lines should be detected TOTAL lines=38 duplicates=7 percent=18.42 """ % (SIMILAR1, SIMILAR2)).strip())
def test(self): sys.stdout = StringIO() try: similar.run(['--ignore-comments', 'input/similar1', 'input/similar2']) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertEquals(output.strip(), """ 7 similar lines in 2 files ==input/similar1:5 ==input/similar2:5 same file as this one. more than 4 identical lines should be detected TOTAL lines=38 duplicates=7 percent=0.184210526316 """.strip())
def test(self): sys.stdout = StringIO() try: similar.run( ['--ignore-comments', 'input/similar1', 'input/similar2']) output = sys.stdout.getvalue() finally: sys.stdout = sys.__stdout__ self.assertEquals( output.strip(), """ 7 similar lines in 2 files ==input/similar1:5 ==input/similar2:5 same file as this one. more than 4 identical lines should be detected TOTAL lines=38 duplicates=7 percent=0.184210526316 """.strip())