refactor: Replace doctest traceback with ... (#7558)

This commit is contained in:
Caeden Perelli-Harris 2022-10-23 15:36:10 +01:00 committed by GitHub
parent 0f06a0b5ff
commit 393b960525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 14 deletions

View File

@ -56,11 +56,7 @@ def pressure_conversion(value: float, from_type: str, to_type: str) -> float:
0.019336718261000002
>>> pressure_conversion(4, "wrongUnit", "atm")
Traceback (most recent call last):
File "/usr/lib/python3.8/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest __main__.pressure_conversion[8]>", line 1, in <module>
pressure_conversion(4, "wrongUnit", "atm")
File "<string>", line 67, in pressure_conversion
...
ValueError: Invalid 'from_type' value: 'wrongUnit' Supported values are:
atm, pascal, bar, kilopascal, megapascal, psi, inHg, torr
"""

View File

@ -25,19 +25,19 @@ def carrier_concentration(
('hole_conc', 1440.0)
>>> carrier_concentration(electron_conc=1000, hole_conc=400, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 37, in <module>
...
ValueError: You cannot supply more or less than 2 values
>>> carrier_concentration(electron_conc=-1000, hole_conc=0, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 40, in <module>
...
ValueError: Electron concentration cannot be negative in a semiconductor
>>> carrier_concentration(electron_conc=0, hole_conc=-400, intrinsic_conc=1200)
Traceback (most recent call last):
File "<stdin>", line 44, in <module>
...
ValueError: Hole concentration cannot be negative in a semiconductor
>>> carrier_concentration(electron_conc=0, hole_conc=400, intrinsic_conc=-1200)
Traceback (most recent call last):
File "<stdin>", line 48, in <module>
...
ValueError: Intrinsic concentration cannot be negative in a semiconductor
"""
if (electron_conc, hole_conc, intrinsic_conc).count(0) != 1:

View File

@ -17,15 +17,15 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
result(name='power', value=6.0)
>>> electric_power(voltage=2, current=4, power=2)
Traceback (most recent call last):
File "<stdin>", line 15, in <module>
...
ValueError: Only one argument must be 0
>>> electric_power(voltage=0, current=0, power=2)
Traceback (most recent call last):
File "<stdin>", line 19, in <module>
...
ValueError: Only one argument must be 0
>>> electric_power(voltage=0, current=2, power=-4)
Traceback (most recent call last):
File "<stdin>", line 23, in <modulei
...
ValueError: Power cannot be negative in any electrical/electronics system
>>> electric_power(voltage=2.2, current=2.2, power=0)
result(name='power', value=4.84)

View File

@ -31,7 +31,6 @@ def neville_interpolate(x_points: list, y_points: list, x0: int) -> list:
104.0
>>> neville_interpolate((1,2,3,4,6), (6,7,8,9,11), '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...
TypeError: unsupported operand type(s) for -: 'str' and 'int'
"""