aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/runtime_py3/test
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
committermonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /library/python/runtime_py3/test
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
downloadydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz
fix ya.make
Diffstat (limited to 'library/python/runtime_py3/test')
-rw-r--r--library/python/runtime_py3/test/.dist-info/METADATA14
-rw-r--r--library/python/runtime_py3/test/.dist-info/RECORD1
-rw-r--r--library/python/runtime_py3/test/.dist-info/entry_points.txt2
-rw-r--r--library/python/runtime_py3/test/.dist-info/top_level.txt1
-rw-r--r--library/python/runtime_py3/test/canondata/result.json50
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stderr.txt12
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stderr.txt13
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stderr.txt27
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stderr.txt12
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stderr.txt13
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stderr.txt27
-rw-r--r--library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stdout.txt2
-rw-r--r--library/python/runtime_py3/test/resources/__init__.py0
-rw-r--r--library/python/runtime_py3/test/resources/foo.txt1
-rw-r--r--library/python/runtime_py3/test/resources/submodule/__init__.py0
-rw-r--r--library/python/runtime_py3/test/resources/submodule/bar.txt1
-rw-r--r--library/python/runtime_py3/test/test_arcadia_source_finder.py344
-rw-r--r--library/python/runtime_py3/test/test_metadata.py44
-rw-r--r--library/python/runtime_py3/test/test_resources.py60
-rw-r--r--library/python/runtime_py3/test/test_traceback.py63
-rw-r--r--library/python/runtime_py3/test/traceback/__main__.py4
-rw-r--r--library/python/runtime_py3/test/traceback/crash.py44
-rw-r--r--library/python/runtime_py3/test/traceback/mod/__init__.py3
28 files changed, 0 insertions, 748 deletions
diff --git a/library/python/runtime_py3/test/.dist-info/METADATA b/library/python/runtime_py3/test/.dist-info/METADATA
deleted file mode 100644
index bb36162199..0000000000
--- a/library/python/runtime_py3/test/.dist-info/METADATA
+++ /dev/null
@@ -1,14 +0,0 @@
-Metadata-Version: 2.1
-Name: foo-bar
-Version: 1.2.3
-Summary:
-Home-page: https://foo.org/
-Author: Foo
-Author-email: foo@ya.com
-License: UNKNOWN
-Platform: any
-Classifier: Development Status :: 4 - Beta
-Classifier: Programming Language :: Python :: 3
-Requires-Python: >=3.8
-Requires-Dist: Werkzeug (>=0.15)
-Requires-Dist: Jinja2 (>=2.10.1)
diff --git a/library/python/runtime_py3/test/.dist-info/RECORD b/library/python/runtime_py3/test/.dist-info/RECORD
deleted file mode 100644
index dabbbff80d..0000000000
--- a/library/python/runtime_py3/test/.dist-info/RECORD
+++ /dev/null
@@ -1 +0,0 @@
-foo_bar.py,sha256=0000000000000000000000000000000000000000000,20
diff --git a/library/python/runtime_py3/test/.dist-info/entry_points.txt b/library/python/runtime_py3/test/.dist-info/entry_points.txt
deleted file mode 100644
index f5e2fd2657..0000000000
--- a/library/python/runtime_py3/test/.dist-info/entry_points.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-[console_scripts]
-foo_cli = foo_bar:cli
diff --git a/library/python/runtime_py3/test/.dist-info/top_level.txt b/library/python/runtime_py3/test/.dist-info/top_level.txt
deleted file mode 100644
index d2c068bc6b..0000000000
--- a/library/python/runtime_py3/test/.dist-info/top_level.txt
+++ /dev/null
@@ -1 +0,0 @@
-foo_bar
diff --git a/library/python/runtime_py3/test/canondata/result.json b/library/python/runtime_py3/test/canondata/result.json
deleted file mode 100644
index 8e684deb43..0000000000
--- a/library/python/runtime_py3/test/canondata/result.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "test_traceback.test_traceback[custom-default]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_custom-default_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_custom-default_/stdout.txt"
- }
- },
- "test_traceback.test_traceback[custom-ultratb_color]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_custom-ultratb_color_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_custom-ultratb_color_/stdout.txt"
- }
- },
- "test_traceback.test_traceback[custom-ultratb_verbose]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_custom-ultratb_verbose_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_custom-ultratb_verbose_/stdout.txt"
- }
- },
- "test_traceback.test_traceback[main-default]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_main-default_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_main-default_/stdout.txt"
- }
- },
- "test_traceback.test_traceback[main-ultratb_color]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_main-ultratb_color_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_main-ultratb_color_/stdout.txt"
- }
- },
- "test_traceback.test_traceback[main-ultratb_verbose]": {
- "stderr": {
- "uri": "file://test_traceback.test_traceback_main-ultratb_verbose_/stderr.txt"
- },
- "stdout": {
- "uri": "file://test_traceback.test_traceback_main-ultratb_verbose_/stdout.txt"
- }
- }
-}
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stderr.txt
deleted file mode 100644
index 5eb7da170a..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stderr.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Traceback (most recent call last):
- File "library/python/runtime_py3/test/traceback/crash.py", line 44, in main
- one()
- File "library/python/runtime_py3/test/traceback/crash.py", line 12, in one
- modfunc(two) # aaa
- File "library/python/runtime_py3/test/traceback/mod/__init__.py", line 3, in modfunc
- f() # call back to caller
- File "library/python/runtime_py3/test/traceback/crash.py", line 16, in two
- three(42)
- File "library/python/runtime_py3/test/traceback/crash.py", line 20, in three
- raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
-RuntimeError: Kaboom! I'm dead: 42
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-default_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stderr.txt
deleted file mode 100644
index af1c19fb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stderr.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Traceback (most recent call last):
- File library/python/runtime_py3/test/traceback/crash.py:44 in main
- one()
- File library/python/runtime_py3/test/traceback/crash.py:12 in one
- modfunc(two) # aaa
- File library/python/runtime_py3/test/traceback/mod/__init__.py:3 in modfunc
- f() # call back to caller
- File library/python/runtime_py3/test/traceback/crash.py:16 in two
- three(42)
- File library/python/runtime_py3/test/traceback/crash.py:20 in three
- raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
-RuntimeError: Kaboom! I'm dead: 42
-
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_color_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stderr.txt
deleted file mode 100644
index d301e8ab4f..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stderr.txt
+++ /dev/null
@@ -1,27 +0,0 @@
----------------------------------------------------------------------------
-RuntimeError Traceback (most recent call last)
-File library/python/runtime_py3/test/traceback/crash.py:44, in main()
- 41 time.time = lambda: 1531996624.0 # Freeze time
- 42 sys.executable = '<traceback test>'
----> 44 one()
-
-File library/python/runtime_py3/test/traceback/crash.py:12, in one()
- 11 def one():
----> 12 modfunc(two)
-
-File library/python/runtime_py3/test/traceback/mod/__init__.py:3, in modfunc(f=<function two>)
- 1 def modfunc(f):
- 2 # lalala
-----> 3 f()
- f = <function two>
-
-File library/python/runtime_py3/test/traceback/crash.py:16, in two()
- 15 def two():
----> 16 three(42)
-
-File library/python/runtime_py3/test/traceback/crash.py:20, in three(x=42)
- 19 def three(x):
----> 20 raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
- x = 42
-
-RuntimeError: Kaboom! I'm dead: 42
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_custom-ultratb_verbose_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stderr.txt
deleted file mode 100644
index 5eb7da170a..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stderr.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Traceback (most recent call last):
- File "library/python/runtime_py3/test/traceback/crash.py", line 44, in main
- one()
- File "library/python/runtime_py3/test/traceback/crash.py", line 12, in one
- modfunc(two) # aaa
- File "library/python/runtime_py3/test/traceback/mod/__init__.py", line 3, in modfunc
- f() # call back to caller
- File "library/python/runtime_py3/test/traceback/crash.py", line 16, in two
- three(42)
- File "library/python/runtime_py3/test/traceback/crash.py", line 20, in three
- raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
-RuntimeError: Kaboom! I'm dead: 42
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-default_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stderr.txt
deleted file mode 100644
index af1c19fb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stderr.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Traceback (most recent call last):
- File library/python/runtime_py3/test/traceback/crash.py:44 in main
- one()
- File library/python/runtime_py3/test/traceback/crash.py:12 in one
- modfunc(two) # aaa
- File library/python/runtime_py3/test/traceback/mod/__init__.py:3 in modfunc
- f() # call back to caller
- File library/python/runtime_py3/test/traceback/crash.py:16 in two
- three(42)
- File library/python/runtime_py3/test/traceback/crash.py:20 in three
- raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
-RuntimeError: Kaboom! I'm dead: 42
-
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_color_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stderr.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stderr.txt
deleted file mode 100644
index d301e8ab4f..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stderr.txt
+++ /dev/null
@@ -1,27 +0,0 @@
----------------------------------------------------------------------------
-RuntimeError Traceback (most recent call last)
-File library/python/runtime_py3/test/traceback/crash.py:44, in main()
- 41 time.time = lambda: 1531996624.0 # Freeze time
- 42 sys.executable = '<traceback test>'
----> 44 one()
-
-File library/python/runtime_py3/test/traceback/crash.py:12, in one()
- 11 def one():
----> 12 modfunc(two)
-
-File library/python/runtime_py3/test/traceback/mod/__init__.py:3, in modfunc(f=<function two>)
- 1 def modfunc(f):
- 2 # lalala
-----> 3 f()
- f = <function two>
-
-File library/python/runtime_py3/test/traceback/crash.py:16, in two()
- 15 def two():
----> 16 three(42)
-
-File library/python/runtime_py3/test/traceback/crash.py:20, in three(x=42)
- 19 def three(x):
----> 20 raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
- x = 42
-
-RuntimeError: Kaboom! I'm dead: 42
diff --git a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stdout.txt b/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stdout.txt
deleted file mode 100644
index 2c9793eb14..0000000000
--- a/library/python/runtime_py3/test/canondata/test_traceback.test_traceback_main-ultratb_verbose_/stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-__name__ = library.python.runtime_py3.test.traceback.crash
-__file__ = library/python/runtime_py3/test/traceback/crash.py
diff --git a/library/python/runtime_py3/test/resources/__init__.py b/library/python/runtime_py3/test/resources/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/library/python/runtime_py3/test/resources/__init__.py
+++ /dev/null
diff --git a/library/python/runtime_py3/test/resources/foo.txt b/library/python/runtime_py3/test/resources/foo.txt
deleted file mode 100644
index ba0e162e1c..0000000000
--- a/library/python/runtime_py3/test/resources/foo.txt
+++ /dev/null
@@ -1 +0,0 @@
-bar \ No newline at end of file
diff --git a/library/python/runtime_py3/test/resources/submodule/__init__.py b/library/python/runtime_py3/test/resources/submodule/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/library/python/runtime_py3/test/resources/submodule/__init__.py
+++ /dev/null
diff --git a/library/python/runtime_py3/test/resources/submodule/bar.txt b/library/python/runtime_py3/test/resources/submodule/bar.txt
deleted file mode 100644
index 1910281566..0000000000
--- a/library/python/runtime_py3/test/resources/submodule/bar.txt
+++ /dev/null
@@ -1 +0,0 @@
-foo \ No newline at end of file
diff --git a/library/python/runtime_py3/test/test_arcadia_source_finder.py b/library/python/runtime_py3/test/test_arcadia_source_finder.py
deleted file mode 100644
index 09ade19043..0000000000
--- a/library/python/runtime_py3/test/test_arcadia_source_finder.py
+++ /dev/null
@@ -1,344 +0,0 @@
-import stat
-import unittest
-import yaml
-from collections import namedtuple
-from unittest.mock import patch
-from parameterized import parameterized
-
-import __res as res
-
-
-NAMESPACE_PREFIX = b'py/namespace/'
-TEST_SOURCE_ROOT = '/home/arcadia'
-
-
-class ImporterMocks(object):
- def __init__(self, mock_fs, mock_resources):
- self._mock_fs = mock_fs
- self._mock_resources = mock_resources
- self._patchers = [
- patch('__res.iter_keys', wraps=self._iter_keys),
- patch('__res.__resource.find', wraps=self._resource_find),
- patch('__res._path_isfile', wraps=self._path_isfile),
- patch('__res._os.listdir', wraps=self._os_listdir),
- patch('__res._os.lstat', wraps=self._os_lstat),
- ]
- for patcher in self._patchers:
- patcher.start()
-
- def stop(self):
- for patcher in self._patchers:
- patcher.stop()
-
- def _iter_keys(self, prefix):
- assert prefix == NAMESPACE_PREFIX
- l = len(prefix)
- for k in self._mock_resources.keys():
- yield k, k[l:]
-
- def _resource_find(self, key):
- return self._mock_resources.get(key)
-
- def _lookup_mock_fs(self, filename):
- path = filename.lstrip('/').split('/')
- curdir = self._mock_fs
- for item in path:
- if item in curdir:
- curdir = curdir[item]
- else:
- return None
- return curdir
-
- def _path_isfile(self, filename):
- f = self._lookup_mock_fs(filename)
- return isinstance(f, str)
-
- def _os_lstat(self, filename):
- f = self._lookup_mock_fs(filename)
- mode = stat.S_IFDIR if isinstance(f, dict) else stat.S_IFREG
- return namedtuple('fake_stat_type', 'st_mode')(st_mode=mode)
-
- def _os_listdir(self, dirname):
- f = self._lookup_mock_fs(dirname)
- if isinstance(f, dict):
- return f.keys()
- else:
- return []
-
-
-class ArcadiaSourceFinderTestCase(unittest.TestCase):
- def setUp(self):
- self.import_mock = ImporterMocks(yaml.safe_load(self._get_mock_fs()), self._get_mock_resources())
- self.arcadia_source_finder = res.ArcadiaSourceFinder(TEST_SOURCE_ROOT)
-
- def tearDown(self):
- self.import_mock.stop()
-
- def _get_mock_fs(self):
- raise NotImplementedError()
-
- def _get_mock_resources(self):
- raise NotImplementedError()
-
-
-class TestLibraryWithoutNamespace(ArcadiaSourceFinderTestCase):
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- project:
- lib:
- mod1.py: ""
- package1:
- mod2.py: ""
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/project/lib': b'project.lib.',
- }
-
- @parameterized.expand([
- ('project.lib.mod1', b'project/lib/mod1.py'),
- ('project.lib.package1.mod2', b'project/lib/package1/mod2.py'),
- ('project.lib.unknown_module', None),
- ('project.lib', None), # package
- ])
- def test_get_module_path(self, module, path):
- assert path == self.arcadia_source_finder.get_module_path(module)
-
- @parameterized.expand([
- ('project.lib.mod1', False),
- ('project.lib.package1.mod2', False),
- ('project', True),
- ('project.lib', True),
- ('project.lib.package1', True),
- ])
- def test_is_packages(self, module, is_package):
- assert is_package == self.arcadia_source_finder.is_package(module)
-
- def test_is_package_for_unknown_module(self):
- self.assertRaises(ImportError, lambda: self.arcadia_source_finder.is_package('project.lib.package2'))
-
- @parameterized.expand([
- ('', {
- ('PFX.project', True),
- }),
- ('project.', {
- ('PFX.lib', True),
- }),
- ('project.lib.', {
- ('PFX.mod1', False),
- ('PFX.package1', True),
- }),
- ('project.lib.package1.', {
- ('PFX.mod2', False),
- }),
- ])
- def test_iter_modules(self, package_prefix, expected):
- got = self.arcadia_source_finder.iter_modules(package_prefix, 'PFX.')
- assert expected == set(got)
-
- # Check iter_modules() don't crash and return correct result after not existing module was requested
- def test_iter_modules_after_unknown_module_import(self):
- self.arcadia_source_finder.get_module_path('project.unknown_module')
- assert {('lib', True)} == set(self.arcadia_source_finder.iter_modules('project.', ''))
-
-
-class TestLibraryExtendedFromAnotherLibrary(ArcadiaSourceFinderTestCase):
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- project:
- lib:
- mod1.py: ''
- lib_extension:
- mod2.py: ''
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/project/lib': b'project.lib.',
- b'py/namespace/unique_prefix2/project/lib_extension': b'project.lib.',
- }
-
- @parameterized.expand([
- ('project.lib.mod1', b'project/lib/mod1.py'),
- ('project.lib.mod2', b'project/lib_extension/mod2.py'),
- ])
- def test_get_module_path(self, module, path):
- assert path == self.arcadia_source_finder.get_module_path(module)
-
- @parameterized.expand([
- ('project.lib.', {
- ('PFX.mod1', False),
- ('PFX.mod2', False),
- }),
- ])
- def test_iter_modules(self, package_prefix, expected):
- got = self.arcadia_source_finder.iter_modules(package_prefix, 'PFX.')
- assert expected == set(got)
-
-
-class TestNamespaceAndTopLevelLibraries(ArcadiaSourceFinderTestCase):
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- project:
- ns_lib:
- mod1.py: ''
- top_level_lib:
- mod2.py: ''
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/project/ns_lib': b'ns.',
- b'py/namespace/unique_prefix2/project/top_level_lib': b'.',
- }
-
- @parameterized.expand([
- ('ns.mod1', b'project/ns_lib/mod1.py'),
- ('mod2', b'project/top_level_lib/mod2.py'),
- ])
- def test_get_module_path(self, module, path):
- assert path == self.arcadia_source_finder.get_module_path(module)
-
- @parameterized.expand([
- ('ns', True),
- ('ns.mod1', False),
- ('mod2', False),
- ])
- def test_is_packages(self, module, is_package):
- assert is_package == self.arcadia_source_finder.is_package(module)
-
- @parameterized.expand([
- 'project',
- 'project.ns_lib',
- 'project.top_level_lib',
- ])
- def test_is_package_for_unknown_modules(self, module):
- self.assertRaises(ImportError, lambda: self.arcadia_source_finder.is_package(module))
-
- @parameterized.expand([
- ('', {
- ('PFX.ns', True),
- ('PFX.mod2', False),
- }),
- ('ns.', {
- ('PFX.mod1', False),
- }),
- ])
- def test_iter_modules(self, package_prefix, expected):
- got = self.arcadia_source_finder.iter_modules(package_prefix, 'PFX.')
- assert expected == set(got)
-
-
-class TestIgnoreDirectoriesWithYaMakeFile(ArcadiaSourceFinderTestCase):
- ''' Packages and modules from tests should not be part of pylib namespace '''
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- contrib:
- python:
- pylib:
- mod1.py: ""
- tests:
- conftest.py: ""
- ya.make: ""
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/contrib/python/pylib': b'pylib.',
- }
-
- def test_get_module_path_for_lib(self):
- assert b'contrib/python/pylib/mod1.py' == self.arcadia_source_finder.get_module_path('pylib.mod1')
-
- def test_get_module_for_tests(self):
- assert self.arcadia_source_finder.get_module_path('pylib.tests.conftest') is None
-
- def test_is_package_for_tests(self):
- self.assertRaises(ImportError, lambda: self.arcadia_source_finder.is_package('pylib.tests'))
-
-
-class TestMergingNamespaceAndDirectoryPackages(ArcadiaSourceFinderTestCase):
- ''' Merge parent package (top level in this test) dirs with namespace dirs (DEVTOOLS-8979) '''
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- contrib:
- python:
- pylint:
- ya.make: ""
- pylint:
- __init__.py: ""
- patcher:
- patch.py: ""
- ya.make: ""
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/contrib/python/pylint': b'.',
- b'py/namespace/unique_prefix1/contrib/python/pylint/patcher': b'pylint.',
- }
-
- @parameterized.expand([
- ('pylint.__init__', b'contrib/python/pylint/pylint/__init__.py'),
- ('pylint.patch', b'contrib/python/pylint/patcher/patch.py'),
- ])
- def test_get_module_path(self, module, path):
- assert path == self.arcadia_source_finder.get_module_path(module)
-
-
-class TestEmptyResources(ArcadiaSourceFinderTestCase):
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- project:
- lib:
- mod1.py: ''
- '''
-
- def _get_mock_resources(self):
- return {}
-
- def test_get_module_path(self):
- assert self.arcadia_source_finder.get_module_path('project.lib.mod1') is None
-
- def test_is_package(self):
- self.assertRaises(ImportError, lambda: self.arcadia_source_finder.is_package('project'))
-
- def test_iter_modules(self):
- assert [] == list(self.arcadia_source_finder.iter_modules('', 'PFX.'))
-
-
-class TestDictionaryChangedSizeDuringIteration(ArcadiaSourceFinderTestCase):
- def _get_mock_fs(self):
- return '''
- home:
- arcadia:
- project:
- lib1:
- mod1.py: ''
- lib2:
- mod2.py: ''
- '''
-
- def _get_mock_resources(self):
- return {
- b'py/namespace/unique_prefix1/project/lib1': b'project.lib1.',
- b'py/namespace/unique_prefix1/project/lib2': b'project.lib2.',
- }
-
- def test_no_crash_on_recusive_iter_modules(self):
- for package in self.arcadia_source_finder.iter_modules('project.', ''):
- for _ in self.arcadia_source_finder.iter_modules(package[0], ''):
- pass
diff --git a/library/python/runtime_py3/test/test_metadata.py b/library/python/runtime_py3/test/test_metadata.py
deleted file mode 100644
index 686c176468..0000000000
--- a/library/python/runtime_py3/test/test_metadata.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import importlib.metadata as im
-
-import pytest
-
-
-@pytest.mark.parametrize("name", ("foo-bar", "foo_bar", "Foo-Bar"))
-def test_distribution(name):
- assert im.distribution(name) is not None
-
-
-def test_unknown_package():
- with pytest.raises(im.PackageNotFoundError):
- im.distribution("bar")
-
-
-def test_version():
- assert im.version("foo-bar") == "1.2.3"
-
-
-def test_metadata():
- assert im.metadata("foo-bar") is not None
-
-
-def test_files():
- files = im.files("foo-bar")
- assert len(files) == 1
- assert files[0].name == "foo_bar.py"
- assert files[0].size == 20
-
-
-def test_requires():
- assert im.requires("foo-bar") == ["Werkzeug (>=0.15)", "Jinja2 (>=2.10.1)"]
-
-
-def test_entry_points():
- entry_points = im.entry_points()
- assert "console_scripts" in entry_points
-
- flg_found = False
- for entry_point in entry_points["console_scripts"]:
- if entry_point.name == "foo_cli" and entry_point.value == "foo_bar:cli":
- flg_found = True
-
- assert flg_found
diff --git a/library/python/runtime_py3/test/test_resources.py b/library/python/runtime_py3/test/test_resources.py
deleted file mode 100644
index a269329f42..0000000000
--- a/library/python/runtime_py3/test/test_resources.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import importlib.resources as ir
-
-import pytest
-
-
-@pytest.mark.parametrize("package, resource", (
- ("resources", "foo.txt"),
- ("resources.submodule", "bar.txt")
-))
-def test_is_resource_good_path(package, resource):
- assert ir.is_resource(package, resource)
-
-
-@pytest.mark.parametrize("package, resource", (
- ("resources", "111.txt"),
- ("resources.submodule", "222.txt")
-))
-def test_is_resource_missing(package, resource):
- assert not ir.is_resource(package, resource)
-
-
-def test_is_resource_subresource_directory():
- # Directories are not resources.
- assert not ir.is_resource("resources", "submodule")
-
-
-@pytest.mark.parametrize("package, resource, expected", (
- ("resources", "foo.txt", b"bar"),
- ("resources.submodule", "bar.txt", b"foo")
-))
-def test_read_binary_good_path(package, resource, expected):
- assert ir.read_binary(package, resource) == expected
-
-
-def test_read_binary_missing():
- with pytest.raises(FileNotFoundError):
- ir.read_binary("resources", "111.txt")
-
-
-@pytest.mark.parametrize("package, resource, expected", (
- ("resources", "foo.txt", "bar"),
- ("resources.submodule", "bar.txt", "foo")
-))
-def test_read_text_good_path(package, resource, expected):
- assert ir.read_text(package, resource) == expected
-
-
-def test_read_text_missing():
- with pytest.raises(FileNotFoundError):
- ir.read_text("resources", "111.txt")
-
-
-@pytest.mark.parametrize("package, expected", (
- ("resources", ["submodule", "foo.txt"]),
- ("resources.submodule", ["bar.txt"])
-))
-def test_contents_good_path(package, expected):
- assert sorted(ir.contents(package)) == sorted(expected)
diff --git a/library/python/runtime_py3/test/test_traceback.py b/library/python/runtime_py3/test/test_traceback.py
deleted file mode 100644
index 82087ce98a..0000000000
--- a/library/python/runtime_py3/test/test_traceback.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function, absolute_import, division
-
-import os
-import re
-
-import pytest
-
-import yatest.common as yc
-
-
-def clean_traceback(traceback):
- traceback = re.sub(br'\033\[(\d|;)+?m', b'', traceback) # strip ANSI codes
- traceback = re.sub(br' at 0x[0-9a-fA-F]+', b'', traceback) # remove object ids
- return traceback
-
-
-@pytest.mark.parametrize('mode', [
- 'default',
- 'ultratb_color',
- 'ultratb_verbose',
-])
-@pytest.mark.parametrize('entry_point', [
- 'main',
- 'custom',
-])
-def test_traceback(mode, entry_point):
- tb_tool = yc.build_path('library/python/runtime_py3/test/traceback/traceback')
- stdout_path = yc.test_output_path('stdout_raw.txt')
- stderr_path = yc.test_output_path('stderr_raw.txt')
- filtered_stdout_path = yc.test_output_path('stdout.txt')
- filtered_stderr_path = yc.test_output_path('stderr.txt')
-
- env = os.environ.copy()
- env.pop('PYTHONPATH', None) # Do not let program peek into its sources on filesystem
- if entry_point == 'custom':
- env['Y_PYTHON_ENTRY_POINT'] = 'library.python.runtime_py3.test.traceback.crash:main'
-
- proc = yc.execute(
- command=[tb_tool, mode],
- env=env,
- stdout=stdout_path,
- stderr=stderr_path,
- check_exit_code=False,
- )
-
- with open(filtered_stdout_path, 'wb') as f:
- f.write(clean_traceback(proc.std_out))
-
- with open(filtered_stderr_path, 'wb') as f:
- f.write(clean_traceback(proc.std_err))
-
- return {
- 'stdout': yc.canonical_file(
- filtered_stdout_path,
- local=True,
- ),
- 'stderr': yc.canonical_file(
- filtered_stderr_path,
- local=True,
- ),
- }
diff --git a/library/python/runtime_py3/test/traceback/__main__.py b/library/python/runtime_py3/test/traceback/__main__.py
deleted file mode 100644
index 364db169f0..0000000000
--- a/library/python/runtime_py3/test/traceback/__main__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from library.python.runtime_py3.test.traceback.crash import main
-
-if __name__ == "__main__":
- main()
diff --git a/library/python/runtime_py3/test/traceback/crash.py b/library/python/runtime_py3/test/traceback/crash.py
deleted file mode 100644
index b5e36b3dd4..0000000000
--- a/library/python/runtime_py3/test/traceback/crash.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import argparse
-import cgitb
-import sys
-import time
-
-from IPython.core import ultratb
-
-from .mod import modfunc
-
-
-def one():
- modfunc(two) # aaa
-
-
-def two():
- three(42)
-
-
-def three(x):
- raise RuntimeError('Kaboom! I\'m dead: {}'.format(x))
-
-
-def main():
- hooks = {
- 'default': lambda: sys.excepthook,
- 'cgitb': lambda: cgitb.Hook(format='text'),
- 'ultratb_color': lambda: ultratb.ColorTB(ostream=sys.stderr),
- 'ultratb_verbose': lambda: ultratb.VerboseTB(ostream=sys.stderr),
- }
-
- parser = argparse.ArgumentParser()
- parser.add_argument('hook', choices=sorted(hooks), default='default')
-
- args = parser.parse_args()
-
- sys.excepthook = hooks[args.hook]()
-
- print('__name__ =', __name__)
- print('__file__ =', __file__)
-
- time.time = lambda: 1531996624.0 # Freeze time
- sys.executable = '<traceback test>'
-
- one()
diff --git a/library/python/runtime_py3/test/traceback/mod/__init__.py b/library/python/runtime_py3/test/traceback/mod/__init__.py
deleted file mode 100644
index f00843d786..0000000000
--- a/library/python/runtime_py3/test/traceback/mod/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-def modfunc(f):
- # lalala
- f() # call back to caller