summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_module/good_getattr.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-22 14:53:49 (GMT)
committerGitHub <noreply@github.com>2023-08-22 14:53:49 (GMT)
commitadfc118fdab66882599e01a84c22bd897055f3f1 (patch)
treef9802048fd55fb2864456ae5173b614229248816 /Lib/test/test_module/good_getattr.py
parente8ef0bdd8c613a722bf7965bf1da912882141a52 (diff)
downloadcpython-adfc118fdab66882599e01a84c22bd897055f3f1.zip
cpython-adfc118fdab66882599e01a84c22bd897055f3f1.tar.gz
cpython-adfc118fdab66882599e01a84c22bd897055f3f1.tar.bz2
gh-106016: Add Lib/test/test_module/ directory (#108293)
* Move Python scripts related to test_module to this new directory: good_getattr.py and bad_getattrX.py scripts. * Move Lib/test/test_module.py to Lib/test/test_module/__init__.py.
Diffstat (limited to 'Lib/test/test_module/good_getattr.py')
-rw-r--r--Lib/test/test_module/good_getattr.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_module/good_getattr.py b/Lib/test/test_module/good_getattr.py
new file mode 100644
index 0000000..7d27de6
--- /dev/null
+++ b/Lib/test/test_module/good_getattr.py
@@ -0,0 +1,11 @@
+x = 1
+
+def __dir__():
+ return ['a', 'b', 'c']
+
+def __getattr__(name):
+ if name == "yolo":
+ raise AttributeError("Deprecated, use whatever instead")
+ return f"There is {name}"
+
+y = 2