From 393b9605259fe19e03bdaac2b0866151e1a2afc2 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sun, 23 Oct 2022 15:36:10 +0100 Subject: [PATCH] refactor: Replace doctest traceback with `...` (#7558) --- conversions/pressure_conversions.py | 6 +----- electronics/carrier_concentration.py | 8 ++++---- electronics/electric_power.py | 6 +++--- maths/nevilles_method.py | 3 +-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/conversions/pressure_conversions.py b/conversions/pressure_conversions.py index 2018080b9..e0cd18d23 100644 --- a/conversions/pressure_conversions.py +++ b/conversions/pressure_conversions.py @@ -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 "", line 1, in - pressure_conversion(4, "wrongUnit", "atm") - File "", line 67, in pressure_conversion + ... ValueError: Invalid 'from_type' value: 'wrongUnit' Supported values are: atm, pascal, bar, kilopascal, megapascal, psi, inHg, torr """ diff --git a/electronics/carrier_concentration.py b/electronics/carrier_concentration.py index 03482f1e3..1fb9f2430 100644 --- a/electronics/carrier_concentration.py +++ b/electronics/carrier_concentration.py @@ -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 "", line 37, in + ... 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 "", line 40, in + ... 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 "", line 44, in + ... 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 "", line 48, in + ... ValueError: Intrinsic concentration cannot be negative in a semiconductor """ if (electron_conc, hole_conc, intrinsic_conc).count(0) != 1: diff --git a/electronics/electric_power.py b/electronics/electric_power.py index ac673d7e3..e59795601 100644 --- a/electronics/electric_power.py +++ b/electronics/electric_power.py @@ -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 "", line 15, in + ... ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=0, power=2) Traceback (most recent call last): - File "", line 19, in + ... ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=2, power=-4) Traceback (most recent call last): - File "", line 23, in >> electric_power(voltage=2.2, current=2.2, power=0) result(name='power', value=4.84) diff --git a/maths/nevilles_method.py b/maths/nevilles_method.py index 5583e4269..1f48b43fb 100644 --- a/maths/nevilles_method.py +++ b/maths/nevilles_method.py @@ -31,8 +31,7 @@ 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 "", line 1, in - ... + ... TypeError: unsupported operand type(s) for -: 'str' and 'int' """ n = len(x_points)