Upgrade package to version 0.7.0
This commit is contained in:
parent
c2bcdc68ac
commit
fd5ef15f01
95
Fix-handling-missing-hypothesmith-gracefully.patch
Normal file
95
Fix-handling-missing-hypothesmith-gracefully.patch
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
From 93d795c1ab502ba6155212b13f437ca43df81154 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
||||||
|
Date: Mon, 24 Jan 2022 11:01:59 +0100
|
||||||
|
Reference: https://github.com/PyCQA/mccabe/pull/92
|
||||||
|
Subject: [PATCH] Fix handling missing hypothesmith gracefully
|
||||||
|
|
||||||
|
---
|
||||||
|
test_mccabe.py | 70 ++++++++++++++++++++++++++------------------------
|
||||||
|
1 file changed, 36 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/test_mccabe.py b/test_mccabe.py
|
||||||
|
index fe6e8d3..5f07d32 100644
|
||||||
|
--- a/test_mccabe.py
|
||||||
|
+++ b/test_mccabe.py
|
||||||
|
@@ -239,41 +239,43 @@ class RegressionTests(unittest.TestCase):
|
||||||
|
self.assertEqual(0, mccabe.get_module_complexity("mccabe.py"))
|
||||||
|
|
||||||
|
|
||||||
|
-# This test uses the Hypothesis and Hypothesmith libraries to generate random
|
||||||
|
-# syntatically-valid Python source code and applies McCabe on it.
|
||||||
|
-@settings(
|
||||||
|
- max_examples=1000, # roughly 1k tests/minute, or half that under coverage
|
||||||
|
- derandomize=False, # deterministic mode to avoid CI flakiness
|
||||||
|
- deadline=None, # ignore Hypothesis' health checks; we already know that
|
||||||
|
- suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
|
||||||
|
-)
|
||||||
|
-@given(
|
||||||
|
- # Note that while Hypothesmith might generate code unlike that written by
|
||||||
|
- # humans, it's a general test that should pass for any *valid* source code.
|
||||||
|
- # (so e.g. running it against code scraped of the internet might also help)
|
||||||
|
- src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
|
||||||
|
- max_complexity=st.integers(min_value=1),
|
||||||
|
-)
|
||||||
|
-@pytest.mark.skipif(not hypothesmith, reason="hypothesmith could not be imported")
|
||||||
|
-def test_idempotent_any_syntatically_valid_python(
|
||||||
|
- src_contents: str, max_complexity: int
|
||||||
|
-) -> None:
|
||||||
|
- """Property-based tests for mccabe.
|
||||||
|
-
|
||||||
|
- This test case is based on a similar test for Black, the code formatter.
|
||||||
|
- Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
|
||||||
|
- and the Hypothesmith tool for source code generation. You can run this
|
||||||
|
- file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
|
||||||
|
- working on.
|
||||||
|
- """
|
||||||
|
-
|
||||||
|
- # Before starting, let's confirm that the input string is valid Python:
|
||||||
|
- compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
|
||||||
|
-
|
||||||
|
- # Then try to apply get_complexity_number to the code...
|
||||||
|
- get_code_complexity(src_contents, max_complexity)
|
||||||
|
+if hypothesmith is not None:
|
||||||
|
+ # This test uses the Hypothesis and Hypothesmith libraries to generate random
|
||||||
|
+ # syntatically-valid Python source code and applies McCabe on it.
|
||||||
|
+ @settings(
|
||||||
|
+ max_examples=1000, # roughly 1k tests/minute, or half that under coverage
|
||||||
|
+ derandomize=False, # deterministic mode to avoid CI flakiness
|
||||||
|
+ deadline=None, # ignore Hypothesis' health checks; we already know that
|
||||||
|
+ suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
|
||||||
|
+ )
|
||||||
|
+ @given(
|
||||||
|
+ # Note that while Hypothesmith might generate code unlike that written by
|
||||||
|
+ # humans, it's a general test that should pass for any *valid* source code.
|
||||||
|
+ # (so e.g. running it against code scraped of the internet might also help)
|
||||||
|
+ src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
|
||||||
|
+ max_complexity=st.integers(min_value=1),
|
||||||
|
+ )
|
||||||
|
+ @pytest.mark.skipif(not hypothesmith, reason="hypothesmith could not be imported")
|
||||||
|
+ def test_idempotent_any_syntatically_valid_python(
|
||||||
|
+ src_contents: str, max_complexity: int
|
||||||
|
+ ) -> None:
|
||||||
|
+ """Property-based tests for mccabe.
|
||||||
|
+
|
||||||
|
+ This test case is based on a similar test for Black, the code formatter.
|
||||||
|
+ Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
|
||||||
|
+ and the Hypothesmith tool for source code generation. You can run this
|
||||||
|
+ file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
|
||||||
|
+ working on.
|
||||||
|
+ """
|
||||||
|
+
|
||||||
|
+ # Before starting, let's confirm that the input string is valid Python:
|
||||||
|
+ compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
|
||||||
|
+
|
||||||
|
+ # Then try to apply get_complexity_number to the code...
|
||||||
|
+ get_code_complexity(src_contents, max_complexity)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
- test_idempotent_any_syntatically_valid_python()
|
||||||
|
+ if hypothesmith is not None:
|
||||||
|
+ test_idempotent_any_syntatically_valid_python()
|
||||||
|
unittest.main()
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
Binary file not shown.
BIN
mccabe-0.7.0.tar.gz
Normal file
BIN
mccabe-0.7.0.tar.gz
Normal file
Binary file not shown.
@ -1,10 +1,11 @@
|
|||||||
Name: python-mccabe
|
Name: python-mccabe
|
||||||
Version: 0.6.1
|
Version: 0.7.0
|
||||||
Release: 11
|
Release: 1
|
||||||
Summary: McCabe complexity checker for Python
|
Summary: McCabe complexity checker for Python
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://pypi.python.org/pypi/mccabe
|
URL: http://pypi.python.org/pypi/mccabe
|
||||||
Source0: https://files.pythonhosted.org/packages/source/m/mccabe/mccabe-%{version}.tar.gz
|
Source0: https://files.pythonhosted.org/packages/source/m/mccabe/mccabe-%{version}.tar.gz
|
||||||
|
Patch0001: Fix-handling-missing-hypothesmith-gracefully.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -40,6 +41,9 @@ for flake8, the Python code checker.
|
|||||||
%{python3_sitelib}/__pycache__/mccabe.*
|
%{python3_sitelib}/__pycache__/mccabe.*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 14 2023 wulei <wu_lei@hoperun.com> - 0.7.0-1
|
||||||
|
- Upgrade package to version 0.7.0
|
||||||
|
|
||||||
* Wed Oct 21 2020 Ge Wang <wangge20@huawei.com> - 0.6.1-11
|
* Wed Oct 21 2020 Ge Wang <wangge20@huawei.com> - 0.6.1-11
|
||||||
- remove python2
|
- remove python2
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user