rix0rrr / cover2cover

Convert JaCoCo coverage reports to Cobertura coverage reports
MIT License
55 stars 50 forks source link

Got an error running with Python3 #8

Closed ggetv closed 1 year ago

ggetv commented 4 years ago

Hi, thanks for this nice conversion script! I found a small error running it under python3:

  File "cover2cover.py", line 147
    print '<?xml version="1.0" ?>'
                                 ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('<?xml version="1.0" ?>')?

Any way to fix that? python2 works fine.

lorenzleutgeb commented 4 years ago
--- cover2cover.py.old    2020-07-13 10:50:27.602377479 +0200
+++ cover2cover.new       2020-07-13 10:50:18.786395875 +0200
@@ -142,12 +143,12 @@

     into = ET.Element('coverage')
     convert_root(root, into, source_roots)
-    print '<?xml version="1.0" ?>'
-    print ET.tostring(into)
+    print('<?xml version="1.0" ?>')
+    print(ET.tostring(into))

 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print "Usage: cover2cover.py FILENAME [SOURCE_ROOTS]"
+        print("Usage: cover2cover.py FILENAME [SOURCE_ROOTS]")
         sys.exit(1)

     filename    = sys.argv[1]
gail-b-stewart commented 2 years ago

The line print(ET.tostring(into)) prints as a byte string for me; i.e. prefixed by "b'" and ending with "'". To fix that change the line to: print(ET.tostring(into).decode()) I am using python 3.10