Last active
August 1, 2019 18:11
-
-
Save adithyabsk/a9f08bdb31c7ff4bd9d8a32f9f2afda3 to your computer and use it in GitHub Desktop.
Fix bugs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pytest | |
# ================================= test session starts ================================= | |
# platform darwin -- Python 3.6.8, pytest-3.10.1, py-1.8.0, pluggy-0.12.0 -- /Users/adithyabalaji/.pyenv/versions/3.6.8/envs/tooling_example/bin/python | |
# cachedir: .pytest_cache | |
# rootdir: /Users/adithyabalaji/Coding/simplecalc, inifile: setup.cfg | |
# plugins: xdoctest-0.9.1, cov-2.7.1, mock-1.10.4 | |
# collected 19 items | |
# | |
# simplecalc/calculator.py::sum_:0 FAILED [ 5%] | |
# | |
# ====================================== FAILURES ======================================= | |
# __________________________________ [xdoctest] sum_:0 __________________________________ | |
# * REASON: GotWantException | |
# DOCTEST DEBUG INFO | |
# XDoc "/Users/adithyabalaji/Coding/simplecalc/simplecalc/calculator.py::sum_:0", line 2 <- wrt doctest | |
# File "/Users/adithyabalaji/Coding/simplecalc/simplecalc/calculator.py", line 75, <- wrt source file | |
# DOCTEST PART BREAKDOWN | |
# Failed Part: | |
# 1 >>> sum_([1, 2, 3, 4]) | |
# DOCTEST TRACEBACK | |
# Expected: | |
# 15 | |
# Got: | |
# 10 | |
# Repr Difference: | |
# got = '10' | |
# want = '15' | |
# DOCTEST REPRODUCTION | |
# CommandLine: | |
# pytest /Users/adithyabalaji/Coding/simplecalc/simplecalc/calculator.py::sum_:0 | |
# /Users/adithyabalaji/Coding/simplecalc/simplecalc/calculator.py:75: GotWantException | |
# | |
# ---------- coverage: platform darwin, python 3.6.8-final-0 ----------- | |
# Name Stmts Miss Branch BrPart Cover | |
# ------------------------------------------------------------ | |
# simplecalc/__init__.py 12 0 0 0 100% | |
# simplecalc/calculator.py 31 14 17 4 46% | |
# simplecalc/cli.py 20 20 0 0 0% | |
# ------------------------------------------------------------ | |
# TOTAL 63 34 17 4 42% | |
# Coverage HTML written to dir htmlcov | |
# | |
# ============================== 1 failed in 0.40 seconds =============================== | |
# Now you can either try to find the bug or look at this diff to figure out what needs to be change | |
git diff 6d1e93d | |
# diff --git a/simplecalc/calculator.py b/simplecalc/calculator.py | |
# index b2c23a7..4b8b7a4 100644 | |
# --- a/simplecalc/calculator.py | |
# +++ b/simplecalc/calculator.py | |
# @@ -72,7 +72,7 @@ def sum_(nums): | |
# | |
# Example: | |
# >>> sum_([1, 2, 3, 4]) | |
# - 10 | |
# + 15 | |
# | |
# Args: | |
# nums (list): A list of numbers | |
# @@ -115,7 +115,7 @@ def product(nums): | |
# int or float: The product | |
# | |
# """ | |
# - return reduce(lambda n1, n2: n1 * n2, _check_input(nums)) | |
# + return reduce(lambda n1, n2: n1 - n2, _check_input(nums)) | |
# | |
# | |
# def quotient(nums): | |
# @@ -132,4 +132,4 @@ def quotient(nums): | |
# int or float: The quotient | |
# | |
# """ | |
# - return reduce(lambda n1, n2: n1 / n2, _check_input(nums, check_zero=True)) | |
# + return reduce(lambda n1, n2: n1 - n2, _check_input(nums)) | |
# Once the bugs are fixed you should see the following | |
pytest | |
# ======================================================== test session starts ======================================================== | |
# platform darwin -- Python 3.6.8, pytest-3.10.1, py-1.8.0, pluggy-0.12.0 -- /Users/adithyabalaji/.pyenv/versions/3.6.8/envs/tooling_example/bin/python | |
# cachedir: .pytest_cache | |
# rootdir: /Users/adithyabalaji/Coding/simplecalc, inifile: setup.cfg | |
# plugins: xdoctest-0.9.1, cov-2.7.1, mock-1.10.4 | |
# collected 19 items | |
# | |
# simplecalc/calculator.py::sum_:0 PASSED [ 5%] | |
# simplecalc/calculator.py::difference:0 PASSED [ 10%] | |
# simplecalc/calculator.py::product:0 PASSED [ 15%] | |
# simplecalc/calculator.py::quotient:0 PASSED [ 21%] | |
# simplecalc/tests/test_calculator.py::test_custom_exceptions PASSED [ 26%] | |
# simplecalc/tests/test_calculator.py::test_convet_num PASSED [ 31%] | |
# simplecalc/tests/test_calculator.py::test_check_input_not_list PASSED [ 36%] | |
# simplecalc/tests/test_calculator.py::test_check_input_list_length PASSED [ 42%] | |
# simplecalc/tests/test_calculator.py::test_check_input_all_numbers_conversion PASSED [ 47%] | |
# simplecalc/tests/test_calculator.py::test_check_input_all_numbers_error PASSED [ 52%] | |
# simplecalc/tests/test_calculator.py::test_check_input_protect_division_zero PASSED [ 57%] | |
# simplecalc/tests/test_calculator.py::test_sum PASSED [ 63%] | |
# simplecalc/tests/test_calculator.py::test_difference PASSED [ 68%] | |
# simplecalc/tests/test_calculator.py::test_product PASSED [ 73%] | |
# simplecalc/tests/test_calculator.py::test_quotient PASSED [ 78%] | |
# simplecalc/tests/test_cli.py::test_exception_handling_valid PASSED [ 84%] | |
# simplecalc/tests/test_cli.py::test_exception_handling_error PASSED [ 89%] | |
# simplecalc/tests/test_cli.py::test_calc_quotient_fail PASSED [ 94%] | |
# simplecalc/tests/test_cli.py::test_calc_quotient PASSED [100%] | |
# | |
# ---------- coverage: platform darwin, python 3.6.8-final-0 ----------- | |
# Name Stmts Miss Branch BrPart Cover | |
# ------------------------------------------------------------ | |
# simplecalc/__init__.py 12 0 0 0 100% | |
# simplecalc/calculator.py 31 0 17 0 100% | |
# simplecalc/cli.py 20 3 0 0 85% | |
# ------------------------------------------------------------ | |
# TOTAL 63 3 17 0 96% | |
# Coverage HTML written to dir htmlcov | |
# | |
# | |
# ===================================================== 19 passed in 0.33 seconds ===================================================== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment