Hello community,

here is the log from the commit of package python3-mccabe for openSUSE:Factory 
checked in at 2015-06-16 14:05:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python3-mccabe (Old)
 and      /work/SRC/openSUSE:Factory/.python3-mccabe.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python3-mccabe"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python3-mccabe/python3-mccabe.changes    
2015-01-10 23:05:34.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.python3-mccabe.new/python3-mccabe.changes       
2015-06-16 14:06:09.000000000 +0200
@@ -1,0 +2,10 @@
+Tue Jun 16 05:14:39 UTC 2015 - a...@gmx.de
+
+- update to version 0.3.1:
+  * Add release machinery to tox.ini
+  * Include test_mccabe.py in releases
+  * Update .travis.yml to use tox
+  * Use travis-ci containers for building
+  * Add travis testing on python 3.4
+
+-------------------------------------------------------------------

Old:
----
  mccabe-0.3.tar.gz

New:
----
  mccabe-0.3.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python3-mccabe.spec ++++++
--- /var/tmp/diff_new_pack.5uvs1e/_old  2015-06-16 14:06:10.000000000 +0200
+++ /var/tmp/diff_new_pack.5uvs1e/_new  2015-06-16 14:06:10.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python3-mccabe
 #
-# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           python3-mccabe
-Version:        0.3
+Version:        0.3.1
 Release:        0
 Summary:        McCabe checker, plugin for flake8
 License:        MIT

++++++ mccabe-0.3.tar.gz -> mccabe-0.3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/MANIFEST.in new/mccabe-0.3.1/MANIFEST.in
--- old/mccabe-0.3/MANIFEST.in  2014-04-25 22:47:01.000000000 +0200
+++ new/mccabe-0.3.1/MANIFEST.in        2015-06-14 20:52:55.000000000 +0200
@@ -1 +1,3 @@
-include LICENSE README.rst
+include LICENSE
+include README.rst
+include test_mccabe.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/PKG-INFO new/mccabe-0.3.1/PKG-INFO
--- old/mccabe-0.3/PKG-INFO     2014-12-17 02:23:10.000000000 +0100
+++ new/mccabe-0.3.1/PKG-INFO   2015-06-14 20:58:06.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: mccabe
-Version: 0.3
+Version: 0.3.1
 Summary: McCabe checker, plugin for flake8
 Home-page: https://github.com/flintwork/mccabe
 Author: Florent Xicluna
@@ -73,6 +73,14 @@
         Changes
         -------
         
+        0.3.1 - 2015-06-14
+        ``````````````````
+        
+        * Include ``test_mccabe.py`` in releases.
+        
+        * Always coerce the ``max_complexity`` value from Flake8's entry-point 
to an
+          integer.
+        
         0.3 - 2014-12-17
         ````````````````
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/README.rst new/mccabe-0.3.1/README.rst
--- old/mccabe-0.3/README.rst   2014-12-17 01:15:26.000000000 +0100
+++ new/mccabe-0.3.1/README.rst 2015-06-14 20:57:32.000000000 +0200
@@ -65,6 +65,14 @@
 Changes
 -------
 
+0.3.1 - 2015-06-14
+``````````````````
+
+* Include ``test_mccabe.py`` in releases.
+
+* Always coerce the ``max_complexity`` value from Flake8's entry-point to an
+  integer.
+
 0.3 - 2014-12-17
 ````````````````
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/mccabe.egg-info/PKG-INFO 
new/mccabe-0.3.1/mccabe.egg-info/PKG-INFO
--- old/mccabe-0.3/mccabe.egg-info/PKG-INFO     2014-12-17 02:23:10.000000000 
+0100
+++ new/mccabe-0.3.1/mccabe.egg-info/PKG-INFO   2015-06-14 20:58:06.000000000 
+0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: mccabe
-Version: 0.3
+Version: 0.3.1
 Summary: McCabe checker, plugin for flake8
 Home-page: https://github.com/flintwork/mccabe
 Author: Florent Xicluna
@@ -73,6 +73,14 @@
         Changes
         -------
         
+        0.3.1 - 2015-06-14
+        ``````````````````
+        
+        * Include ``test_mccabe.py`` in releases.
+        
+        * Always coerce the ``max_complexity`` value from Flake8's entry-point 
to an
+          integer.
+        
         0.3 - 2014-12-17
         ````````````````
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/mccabe.egg-info/SOURCES.txt 
new/mccabe-0.3.1/mccabe.egg-info/SOURCES.txt
--- old/mccabe-0.3/mccabe.egg-info/SOURCES.txt  2014-12-17 02:23:10.000000000 
+0100
+++ new/mccabe-0.3.1/mccabe.egg-info/SOURCES.txt        2015-06-14 
20:58:06.000000000 +0200
@@ -4,6 +4,7 @@
 mccabe.py
 setup.cfg
 setup.py
+test_mccabe.py
 mccabe.egg-info/PKG-INFO
 mccabe.egg-info/SOURCES.txt
 mccabe.egg-info/dependency_links.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/mccabe.py new/mccabe-0.3.1/mccabe.py
--- old/mccabe-0.3/mccabe.py    2014-12-17 02:21:04.000000000 +0100
+++ new/mccabe-0.3.1/mccabe.py  2015-06-14 20:55:36.000000000 +0200
@@ -14,7 +14,7 @@
 except ImportError:   # Python 2.5
     from flake8.util import ast, iter_child_nodes
 
-__version__ = '0.3'
+__version__ = '0.3.1'
 
 
 class ASTVisitor(object):
@@ -236,7 +236,7 @@
 
     @classmethod
     def parse_options(cls, options):
-        cls.max_complexity = options.max_complexity
+        cls.max_complexity = int(options.max_complexity)
 
     def run(self):
         if self.max_complexity < 0:
@@ -296,7 +296,8 @@
     if options.dot:
         print('graph {')
         for graph in visitor.graphs.values():
-            if not options.threshold or graph.complexity() >= 
options.threshold:
+            if (not options.threshold or
+                    graph.complexity() >= options.threshold):
                 graph.to_dot()
         print('}')
     else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/setup.cfg new/mccabe-0.3.1/setup.cfg
--- old/mccabe-0.3/setup.cfg    2014-12-17 02:23:10.000000000 +0100
+++ new/mccabe-0.3.1/setup.cfg  2015-06-14 20:58:06.000000000 +0200
@@ -2,7 +2,7 @@
 universal = 1
 
 [egg_info]
-tag_svn_revision = 0
 tag_date = 0
 tag_build = 
+tag_svn_revision = 0
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mccabe-0.3/test_mccabe.py 
new/mccabe-0.3.1/test_mccabe.py
--- old/mccabe-0.3/test_mccabe.py       1970-01-01 01:00:00.000000000 +0100
+++ new/mccabe-0.3.1/test_mccabe.py     2015-06-14 20:51:46.000000000 +0200
@@ -0,0 +1,189 @@
+import unittest
+import sys
+try:
+    from StringIO import StringIO
+except ImportError:
+    from io import StringIO
+
+import mccabe
+from mccabe import get_code_complexity
+
+
+# Snippets are put outside of testcases because of spacing issue that would
+# otherwise occur with triple quoted strings.
+trivial = 'def f(): pass'
+
+
+sequential = """\
+def f(n):
+    k = n + 4
+    s = k + n
+    return s
+"""
+
+
+sequential_unencapsulated = """\
+k = 2 + 4
+s = k + 3
+"""
+
+
+if_elif_else_dead_path = """\
+def f(n):
+    if n > 3:
+        return "bigger than three"
+    elif n > 4:
+        return "is never executed"
+    else:
+        return "smaller than or equal to three"
+"""
+
+
+for_loop = """\
+def f():
+    for i in range(10):
+        print(i)
+"""
+
+
+for_else = """\
+def f(mylist):
+    for i in mylist:
+        print(i)
+    else:
+        print(None)
+"""
+
+
+recursive = """\
+def f(n):
+    if n > 4:
+        return f(n - 1)
+    else:
+        return n
+"""
+
+
+nested_functions = """\
+def a():
+    def b():
+        def c():
+            pass
+        c()
+    b()
+"""
+
+try_else = """\
+try:
+    print(1)
+except TypeA:
+    print(2)
+except TypeB:
+    print(3)
+else:
+    print(4)
+"""
+
+
+def get_complexity_number(snippet, strio, max=0):
+    """Get the complexity number from the printed string."""
+    # Report from the lowest complexity number.
+    get_code_complexity(snippet, max)
+    strio_val = strio.getvalue()
+    if strio_val:
+        return int(strio_val.split()[-1].strip("()"))
+    else:
+        return None
+
+
+class McCabeTestCase(unittest.TestCase):
+    def setUp(self):
+        # If not assigned to sys.stdout then getvalue() won't capture anything.
+        self._orig_stdout = sys.stdout
+        sys.stdout = self.strio = StringIO()
+
+    def tearDown(self):
+        # https://mail.python.org/pipermail/tutor/2012-January/088031.html
+        self.strio.close()
+        sys.stdout = self._orig_stdout
+
+    def assert_complexity(self, snippet, max):
+        complexity = get_complexity_number(snippet, self.strio)
+        self.assertEqual(complexity, max)
+
+        # should have the same complexity when inside a function as well.
+        infunc = 'def f():\n    ' + snippet.replace('\n', '\n    ')
+        complexity = get_complexity_number(infunc, self.strio)
+        self.assertEqual(complexity, max)
+
+    def test_print_message(self):
+        get_code_complexity(sequential, 0)
+        printed_message = self.strio.getvalue()
+        self.assertEqual(printed_message,
+                         "stdin:1:1: C901 'f' is too complex (1)\n")
+
+    def test_sequential_snippet(self):
+        complexity = get_complexity_number(sequential, self.strio)
+        self.assertEqual(complexity, 1)
+
+    def test_sequential_unencapsulated_snippet(self):
+        complexity = get_complexity_number(sequential_unencapsulated,
+                                           self.strio)
+        self.assertEqual(complexity, None)
+
+    def test_if_elif_else_dead_path_snippet(self):
+        complexity = get_complexity_number(if_elif_else_dead_path, self.strio)
+        # Paths that will never be executed are counted!
+        self.assertEqual(complexity, 3)
+
+    def test_for_loop_snippet(self):
+        complexity = get_complexity_number(for_loop, self.strio)
+        # The for loop adds an execution path; sometimes it won't be run.
+        self.assertEqual(complexity, 2)
+
+    def test_for_else_snippet(self):
+        complexity = get_complexity_number(for_else, self.strio)
+        # The for loop doesn't add an execution path, but its `else` does
+        self.assertEqual(complexity, 2)
+
+    def test_recursive_snippet(self):
+        complexity = get_complexity_number(recursive, self.strio)
+        self.assertEqual(complexity, 2)
+
+    def test_nested_functions_snippet(self):
+        complexity = get_complexity_number(nested_functions, self.strio)
+        self.assertEqual(complexity, 3)
+
+    def test_trivial(self):
+        """The most-trivial program should pass a max-complexity=1 test"""
+        complexity = get_complexity_number(trivial, self.strio, max=1)
+        self.assertEqual(complexity, None)
+        printed_message = self.strio.getvalue()
+        self.assertEqual(printed_message, "")
+
+    def test_try_else(self):
+        self.assert_complexity(try_else, 4)
+
+
+class RegressionTests(unittest.TestCase):
+    def setUp(self):
+        self.original_complexity = mccabe.McCabeChecker.max_complexity
+
+    def tearDown(self):
+        mccabe.McCabeChecker.max_complexity = self.original_complexity
+
+    def test_max_complexity_is_always_an_int(self):
+        """Ensure bug #32 does not regress."""
+        class _options(object):
+            max_complexity = None
+
+        options = _options()
+        options.max_complexity = '16'
+
+        self.assertEqual(0, mccabe.McCabeChecker.max_complexity)
+        mccabe.McCabeChecker.parse_options(options)
+        self.assertEqual(16, mccabe.McCabeChecker.max_complexity)
+
+
+if __name__ == "__main__":
+    unittest.main()


Reply via email to