foxmath 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {foxmath-0.1.1 → foxmath-0.1.2}/PKG-INFO +1 -1
- {foxmath-0.1.1 → foxmath-0.1.2}/pyproject.toml +1 -1
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath/foxmath.py +6 -3
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath.egg-info/PKG-INFO +1 -1
- {foxmath-0.1.1 → foxmath-0.1.2}/tests/test_cli.py +9 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/LICENSE +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/README.md +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/setup.cfg +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath/__init__.py +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath.egg-info/SOURCES.txt +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath.egg-info/dependency_links.txt +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath.egg-info/entry_points.txt +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/src/foxmath.egg-info/top_level.txt +0 -0
- {foxmath-0.1.1 → foxmath-0.1.2}/tests/test_foxmath.py +0 -0
|
@@ -112,17 +112,20 @@ def main():
|
|
|
112
112
|
if cmd == "legendre" or args.command == "legendre":
|
|
113
113
|
ls = legendre_symbol(args.a, args.p)
|
|
114
114
|
result.update({"command": "legendre", "a": args.a, "p": args.p, "value": ls})
|
|
115
|
-
|
|
115
|
+
if not json_output:
|
|
116
|
+
print(f"Legendre ({args.a}/{args.p}) = {ls}")
|
|
116
117
|
|
|
117
118
|
elif cmd == "pi" or args.command == "pi":
|
|
118
119
|
approx = catalan_pi_approx(args.terms)
|
|
119
120
|
result.update({"command": "pi", "terms": args.terms, "approx": str(approx)})
|
|
120
|
-
|
|
121
|
+
if not json_output:
|
|
122
|
+
print(f"π ≈ {approx} ({args.terms} terms)")
|
|
121
123
|
|
|
122
124
|
elif cmd == "ecadd" or args.command == "ecadd":
|
|
123
125
|
x3, y3 = ec_point_add(args.x1, args.y1, args.x2, args.y2, args.a, args.p)
|
|
124
126
|
result.update({"command": "ecadd", "result": (x3, y3)})
|
|
125
|
-
|
|
127
|
+
if not json_output:
|
|
128
|
+
print(f"Result point: ({x3}, {y3})")
|
|
126
129
|
|
|
127
130
|
except Exception as e:
|
|
128
131
|
print(f"Error: {e}", file=sys.stderr)
|
|
@@ -38,6 +38,15 @@ class TestJsonFlag(unittest.TestCase):
|
|
|
38
38
|
self.assertEqual(code, 0)
|
|
39
39
|
self.assertNotIn("{", out)
|
|
40
40
|
|
|
41
|
+
def test_json_output_is_pure_json_no_preamble(self):
|
|
42
|
+
# Regression check: --json used to still print the human-readable
|
|
43
|
+
# line first, breaking anything piping stdout into a JSON parser.
|
|
44
|
+
code, out, err = run("pi", "--terms", "20", "--json")
|
|
45
|
+
self.assertEqual(code, 0)
|
|
46
|
+
import json
|
|
47
|
+
parsed = json.loads(out) # raises if there's any leading text
|
|
48
|
+
self.assertEqual(parsed["command"], "pi")
|
|
49
|
+
|
|
41
50
|
|
|
42
51
|
class TestSymlinkInvocation(unittest.TestCase):
|
|
43
52
|
def setUp(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|