diff --git a/lib/a_name_error.py b/lib/a_name_error.py index 841d7921b..2a41a5d68 100644 --- a/lib/a_name_error.py +++ b/lib/a_name_error.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -print(hello_world) +print('hello_world') diff --git a/lib/a_syntax_error.py b/lib/a_syntax_error.py index 0ba09ba5b..864ea00ad 100644 --- a/lib/a_syntax_error.py +++ b/lib/a_syntax_error.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -poor_syntax = 2 * # +poor_syntax = 2 * 3 diff --git a/lib/a_type_error.py b/lib/a_type_error.py index db7a7f238..61830a929 100644 --- a/lib/a_type_error.py +++ b/lib/a_type_error.py @@ -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) diff --git a/lib/an_assertion_error.py b/lib/an_assertion_error.py index 3f12d9bf4..135f7ef68 100644 --- a/lib/an_assertion_error.py +++ b/lib/an_assertion_error.py @@ -1,3 +1,4 @@ #!/usr/bin/env python3 -assert(1 == 2) +assert 1 == 1 + diff --git a/lib/testing/lib_test.py b/lib/testing/lib_test.py index 628bcf039..555d2d739 100644 --- a/lib/testing/lib_test.py +++ b/lib/testing/lib_test.py @@ -2,6 +2,7 @@ import runpy + class TestNameError: ''' a_name_error.py @@ -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: '''