From 130b18d09ce73992f64079aac839321cc9f81c21 Mon Sep 17 00:00:00 2001 From: Shaddy Date: Tue, 21 Nov 2023 22:46:47 +0300 Subject: [PATCH 1/4] done with first error --- lib/a_name_error.py | 2 +- lib/a_syntax_error.py | 2 +- lib/testing/lib_test.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/testing/lib_test.py b/lib/testing/lib_test.py index 628bcf039..e4f73c72d 100644 --- a/lib/testing/lib_test.py +++ b/lib/testing/lib_test.py @@ -12,7 +12,7 @@ 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: ''' From 382f5b35ccadbeec0e56c9fbef5cf49342d9844d Mon Sep 17 00:00:00 2001 From: Shaddy Date: Tue, 21 Nov 2023 22:47:35 +0300 Subject: [PATCH 2/4] done --- lib/a_syntax_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/a_syntax_error.py b/lib/a_syntax_error.py index 864ea00ad..25408dd65 100644 --- a/lib/a_syntax_error.py +++ b/lib/a_syntax_error.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -poor_syntax = 2 * 3 +poor_syntax = 2 * 3 # From fa106ef59bdbeb5de577fd81e1f7cc417ccab340 Mon Sep 17 00:00:00 2001 From: Shaddy Date: Wed, 22 Nov 2023 12:12:45 +0300 Subject: [PATCH 3/4] fixed another error in a_type_error.py --- lib/a_syntax_error.py | 2 +- lib/a_type_error.py | 13 +++++++++++-- lib/an_assertion_error.py | 3 ++- lib/testing/lib_test.py | 4 +++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/a_syntax_error.py b/lib/a_syntax_error.py index 25408dd65..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 * 3 # +poor_syntax = 2 * 3 diff --git a/lib/a_type_error.py b/lib/a_type_error.py index db7a7f238..317db90a6 100644 --- a/lib/a_type_error.py +++ b/lib/a_type_error.py @@ -1,3 +1,12 @@ -#!/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): + 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..d534c84ba 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 == 2 + diff --git a/lib/testing/lib_test.py b/lib/testing/lib_test.py index e4f73c72d..f76933642 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: ''' From b261e869c15dec310ccd407763ed6184e41b6f92 Mon Sep 17 00:00:00 2001 From: Shaddy Date: Wed, 22 Nov 2023 12:46:20 +0300 Subject: [PATCH 4/4] assertion error fixed --- lib/a_type_error.py | 1 + lib/an_assertion_error.py | 2 +- lib/testing/lib_test.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/a_type_error.py b/lib/a_type_error.py index 317db90a6..61830a929 100644 --- a/lib/a_type_error.py +++ b/lib/a_type_error.py @@ -9,4 +9,5 @@ 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 d534c84ba..135f7ef68 100644 --- a/lib/an_assertion_error.py +++ b/lib/an_assertion_error.py @@ -1,4 +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 f76933642..555d2d739 100644 --- a/lib/testing/lib_test.py +++ b/lib/testing/lib_test.py @@ -13,7 +13,7 @@ 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: