mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
Clean Code: Python
Fix issues found by flake8-bugbear: * Unused loop variables * assert statements in non-test code * mixing test code with production code * mark one excessive test which takes ~10min to run as 'slow'
This commit is contained in:
@@ -142,7 +142,7 @@ def calculate_day_of_week(year, month, day):
|
||||
|
||||
|
||||
def end():
|
||||
for i in range(5):
|
||||
for _ in range(5):
|
||||
print()
|
||||
|
||||
|
||||
@@ -259,26 +259,6 @@ def main():
|
||||
end()
|
||||
|
||||
|
||||
def test_weekday_calc(year, month, day):
|
||||
dt = datetime.date(year, month, day)
|
||||
python_weekday = dt.weekday() # Monday = 0, Sunday = 6
|
||||
|
||||
basic_weekday = calculate_day_of_week(year, month, day) # Sunday = 1, Saturday = 7
|
||||
|
||||
if ((python_weekday + 2) % 7) != (basic_weekday % 7):
|
||||
print(f"testing yr {year} month {month} day {day}")
|
||||
print(f"python says {python_weekday}")
|
||||
print(f"BASIC says {basic_weekday}")
|
||||
assert False
|
||||
|
||||
|
||||
def test_harness():
|
||||
for yr in range(1600, 2021):
|
||||
for m in range(1, 12):
|
||||
for d in range(1, 28):
|
||||
test_weekday_calc(yr, m, d)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user