Esempio n. 1
0
    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(),
        )
Esempio n. 2
0
 def test_no_args(self):
     sys.stdout = StringIO()
     try:
         try:
             similar.run([])
         except SystemExit, ex:
             self.assertEquals(ex.code, 1)
         else:
Esempio n. 3
0
 def test_help(self):
     sys.stdout = StringIO()
     try:
         try:
             similar.run(['--help'])
         except SystemExit, ex:
             self.assertEquals(ex.code, 0)
         else:
Esempio n. 4
0
 def test_no_args(self):
     sys.stdout = StringIO()
     try:
         try:
             similar.run([])
         except SystemExit, ex:
             self.assertEqual(ex.code, 1)
         else:
Esempio n. 5
0
 def test_help(self):
     sys.stdout = StringIO()
     try:
         try:
             similar.run(['--help'])
         except SystemExit, ex:
             self.assertEqual(ex.code, 0)
         else:
Esempio n. 6
0
    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())
Esempio n. 7
0
    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(),
        )
Esempio n. 8
0
    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())
Esempio n. 9
0
    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())
Esempio n. 10
0
    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())