Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Add simple tests for create_builtin()
  • Loading branch information
dr-carlos committed Nov 28, 2025
commit 035017723744d2a0ec96855d752e3a5942cc0a47
22 changes: 22 additions & 0 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,28 @@ class Spec2:
origin = "a\x00b"
_imp.create_dynamic(Spec2())

def test_create_builtin(self):
class Spec:
name = None
spec = Spec()

with self.assertRaisesRegex(
TypeError,
'name must be string, not NoneType'
):
Comment thread
dr-carlos marked this conversation as resolved.
Outdated
_imp.create_builtin(spec)

class Spec:
name = ""
spec = Spec()
Comment thread
dr-carlos marked this conversation as resolved.
Outdated

# gh-142029
with self.assertRaisesRegex(
TypeError,
'name must not be empty'
):
Comment thread
dr-carlos marked this conversation as resolved.
Outdated
_imp.create_builtin(spec)

def test_filter_syntax_warnings_by_module(self):
module_re = r'test\.test_import\.data\.syntax_warnings\z'
unload('test.test_import.data.syntax_warnings')
Expand Down
Loading