Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/a_name_error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python3

print(hello_world)
print('hello_world')
2 changes: 1 addition & 1 deletion lib/a_syntax_error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python3

poor_syntax = 2 * #
poor_syntax = 2 * 3
14 changes: 12 additions & 2 deletions lib/a_type_error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/usr/bin/env python3
# lib_test.py

wrong_type = 'abc' + 123
import pytest
import lib.a_type_error # Import the module directly

class TestTypeError:
def test_type_error(self):
'''
adds two numbers
'''
with pytest.raises(TypeError):
# Execute the code directly without using runpy.run_path
lib.a_type_error.wrong_type = 'abc' + str(123)
3 changes: 2 additions & 1 deletion lib/an_assertion_error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3

assert(1 == 2)
assert 1 == 1

4 changes: 3 additions & 1 deletion lib/testing/lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import runpy


class TestNameError:
'''
a_name_error.py
Expand All @@ -12,7 +13,8 @@ def test_name_error(self):
contains defined name "hello_world"
'''

runpy.run_path('lib/a_name_error.py')
runpy.run_path('./lib/a_name_error.py')


class TestSyntaxError:
'''
Expand Down