2816 Commits

Author SHA1 Message Date
Jeong, YunWon
f541ca9dda Require cpu resource to test_search_anchor_at_beginning (#5218)
cherry-pick python/cpython#117616

Co-authored-by: CPython Developers <>
2024-04-09 01:01:46 +09:00
Hunter Harloff
f6569313d7 Move test_itertools to CPython 3.12 Spec 2024-04-06 19:14:58 +09:00
Jeong, YunWon
e349b0f18b Merge pull request #5125 from qingshi163/sre-dev
Update Sre Engine Implementing to CPython 3.12
2024-03-30 18:50:00 +09:00
Jeong, YunWon
7be6308248 Merge pull request #5206 from dchiquito/fix-test-zipfile
Increase threshold for zipfile test_many_opens
2024-03-28 17:03:47 +09:00
Kangzhi Shi
57e7f4db95 bump string.py mark passed tests 2024-03-22 14:59:19 +09:00
Kangzhi Shi
d9375b9fe1 impl re.template(),
template_compile template_expand subx
2024-03-22 14:59:19 +09:00
Kangzhi Shi
1e3d57817c Replace re_test.py from CPython 3.12 and mark failed tests 2024-03-22 14:59:09 +09:00
Daniel Chiquito
df363c0ba7 Skip typing test which causes other failures (#5207) 2024-03-22 10:26:40 +09:00
Daniel Chiquito
0a24e106ba Increase threshold for zipfile test_many_opens
It turns out that there are many other tests that can impact
test_many_opens by leaving unclosed file handles. Rather than fix them
all, it is easier to simply increase the threshold for the problematic
test.
2024-03-21 13:37:46 -04:00
Daniel Chiquito
e6c73883ea Revert test skip 2024-03-21 13:36:28 -04:00
Daniel Chiquito
e315077630 Add TODO: RUSTPYTHON to skip reason 2024-03-21 11:31:03 -04:00
Daniel Chiquito
5ee5531f32 Properly unload modules between tests (#5192)
There seems to have been a bug in the libregrtest code which unloaded
modules between tests. The previous state was calculated using
`sys.modules.keys()`, which is actually a mutable object that is updated
as the underlying `sys.modules` is updated. The result was that modules
were not unloaded between tests, which is the root cause for
`test_unittest` failing when run after `test_import` and
`test_importlib`.

This code is copied from 3.12. Ideally all of `libregrtest` should
probably be updated as it seems wildly out of date, but that's a lot
more work.
2024-03-21 21:51:57 +09:00
Daniel Chiquito
ac78517044 Skip TestScander.test_uninstantiable (#5204)
This test was marked as an expected failure. Because the garbage
collector is missing, that meant that the `os.scandir` object went
unclosed. This object was squatting on the file descriptors of all the
files contained in the test directory, which was breaking test_zipfile.
2024-03-21 14:44:03 +09:00
Nikita Sobolev
426e582ba0 Remove incorrect @expectedFailures from test_cmd_line (#5201)
After you suggestion in https://github.com/python/cpython/issues/116504#issuecomment-1999239012 I went to take a look at `test_cmd_line` in RustPython (it was so long ago I contributed to this amazing project, so may thing had changed!), and I've noticed this.

This is a problem, here' the simplest demo:

```python
import unittest

class TestMe(unittest.TestCase):
    @unittest.expectedFailure
    def test_me(self):
        def run():
            raise ValueError

        with self.subTest(run=run):
            run()

if __name__ == '__main__':
    unittest.main()
```

This works as expected:

```
» ./python.exe ex.py
x
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK (expected failures=1)
```

This does not:

```python
import unittest

class TestMe(unittest.TestCase):
    def test_me(self):
        @unittest.expectedFailure
        def run():
            raise ValueError

        with self.subTest(run=run):
            run()

if __name__ == '__main__':
    unittest.main()
```

Produces:

```
» ./python.exe ex.py
E
======================================================================
ERROR: test_me (__main__.TestMe.test_me) (run=<function TestMe.test_me.<locals>.run at 0x1057a2150>)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython2/ex.py", line 10, in test_me
    run()
    ~~~^^
  File "/Users/sobolev/Desktop/cpython2/ex.py", line 7, in run
    raise ValueError
ValueError

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)
```

So, I propose to remove these decorators, let's only keep `TODO` comments to indicate separate failures.
2024-03-15 22:15:45 +09:00
Kirill Podoprigora
92c8b371ae Update colorsys.py and test_colorsys.py to 3.12 (#5198) 2024-03-13 15:22:57 +09:00
Kirill Podoprigora
855fa1411f Update ftplib and test_ftplib to 3.12 (#5196) 2024-03-13 07:35:16 +09:00
Kirill Podoprigora
4e7b3bc8f2 Update pprint.py and test_pprint.py to 3.12 (#5195) 2024-03-12 22:36:10 +09:00
Kirill Podoprigora
83d1ad8a2c Update test_operator.py to 3.12 (#5194) 2024-03-12 22:35:21 +09:00
Kirill Podoprigora
7f02324dce Update Lib/test/test_hmac.py to 3.12 version (#5188) 2024-03-11 22:04:35 +09:00
Jeong, YunWon
d453026d19 Merge pull request #5191 from dchiquito/fix-failing-tests
Fix convenient failing tests
2024-03-11 15:03:39 +09:00
wellweek
2fde8e91e5 fix some typos (#5187)
Signed-off-by: wellweek <xiezitai@outlook.com>
2024-03-11 15:01:37 +09:00
Daniel Chiquito
23ebbd021b Skip test_format.test_locale
I had previously `test_locale` as expected to fail, as it did indeed
fail on my system due to unimplemented functionality. As it happens, it
passes in CI because the locale settings used there (`C`, I believe)
just happen to format integers the same with "%d" as "%n".

I mistakenly un-marked it because I thought I misunderstood the problem.
2024-03-10 22:53:39 -04:00
Daniel Chiquito
9b974bda0d Re-enable test_format.test_locale
Technically speaking, my system was misconfigured, leading me to disable
the test in the first place.

`test_locale` calls `locale.setlocale(locale.LC_ALL, '')`, which reads
the value of the `LANG` environment variable and uses that to look up
and reset all the locale settings. My system has `LANG=en_US.UTF-8`,
which is apparently not what this test was expecting. If `LANG` is unset
or set to `C`, the test passes, as it does in CI.
2024-03-10 22:30:41 -04:00
Daniel Chiquito
de7e4e49da Disable broken test_socket.py tests
There are a substantial number of socket tests that are disabled due to
`bind(): bad family` errors. It seems like RustPython only supports a
small subset of the required connection families, so the failing tests
are broken for the same reasons.
2024-03-09 18:22:57 -05:00
Daniel Chiquito
ead42beff6 Disable test_locale in test_format.py
See https://github.com/RustPython/RustPython/issues/5181
2024-03-09 18:22:57 -05:00
Daniel Chiquito
35229721ea Fix test_cmd_line.py
The failing test was unsetting `PYTHONPATH`, but neglecting to unset
`RUSTPYTHONPATH`, which obviously was not significant for the original
CPython test. Including `RUSTPYTHONPATH` in the test fixes it.
2024-03-09 18:22:57 -05:00
Blues-star
e4be47a08b Mark failing tests as expectedFailure 2024-03-05 15:10:35 +09:00
Blues-star
d2bf69e354 Update test_csv.py from CPython v3.12.0 2024-03-05 15:10:35 +09:00
Daniel Chiquito
407f251866 Un-skip passing typing test
I missed that the typing test I disabled was on a base test class.
Moving the expected failure to the subclass allows the passing test to
pass.
2024-02-24 13:33:17 -05:00
Daniel Chiquito
6cd9e54427 Update test_ordered_dict.py to 3.12.2 2024-02-24 12:00:07 -05:00
Daniel Chiquito
c9ec4507ad Disable broken test_repr in test_typing.py
This should be resolved when `typing.py` and `test_typing.py` are
updated to 3.12.
2024-02-24 11:58:26 -05:00
Daniel Chiquito
9481df23e1 Disable test_Buffer
This test will not work until the `__buffer__` and `__release_buffer__`
methods are implemented on the appropriate builtin types, which is
outside the current scope.
2024-02-24 11:02:41 -05:00
Daniel Chiquito
0bd8c2504c Update test_collections.py to 3.12.2 2024-02-23 20:16:16 -05:00
Jeong, YunWon
a8ab7dd388 Merge pull request #5175 from Blues-star/copy
Update `copy.py` and `test_copy.py` from CPython v3.12
2024-02-21 12:02:54 +09:00
Blues-star
83b8c3a3fc Update test_copy.py from CPython v3.12.0 2024-02-20 19:38:58 +08:00
Blues-star
572053df82 est_co_lnotab_is_deprecated, 'test_invalid_bytecode' and est_code_hash_uses_bytecode test exceptions, add TODO 2024-02-19 20:30:06 +08:00
Blues-star
def5661728 Update test_code.py from CPython v3.12.0 2024-02-19 20:13:59 +08:00
Blues-star
d061837467 Update test_configparser.py from CPython v3.12.0 2024-02-19 19:25:17 +08:00
Blues-star
258342e1ca Update test_calendar.py from CPython v3.12.0 2024-02-18 15:36:45 +08:00
Jeong, YunWon
1c93c1630b Merge pull request #5164 from dchiquito/frozenset-hash
Use CPython hash algorithm for frozenset
2024-02-10 14:55:24 +09:00
Daniel Chiquito
074d228a7a Use correct TODO syntax
Co-authored-by: fanninpm <luxverdans@sbcglobal.net>
2024-02-09 21:41:45 -05:00
Daniel Chiquito
bf461cdebc Use CPython hash algorithm for frozenset
The original hash algorithm just XOR'd all the hashes of the elements of
the set, which is problematic. The CPython algorithm is required to pass
the tests.

- Replace `PyFrozenSet::hash` with CPython's algorithm
- Remove unused `hash_iter_unorded` functions
- Add `frozenset` benchmark
- Enable tests
- Lower performance expectations on effectiveness test
- Adjust `slot::hash_wrapper` so that it doesn't rehash the computed
  hash value in the process of converting PyInt to PyHash.
2024-02-09 21:02:40 -05:00
Daniel Chiquito
ffc52ef87c Removed unused __bool__ methods
Python does not define `list().__bool__`, `dict().__bool__`, and
`str().__bool__`, and some tests were failing because they were
defined.
I could not find any references to them and deleting them doesn't
seem to break anything.
2024-02-09 20:58:17 -05:00
kingiler
bdf228eb42 Fix bug in binascii uu encoding. Pass more related unit tests. (#5160)
* Fix bug in binascii, passes more unit tests.

* Pass more additional tests due to this PR.
2024-02-09 22:42:39 +09:00
Daniel Chiquito
43d7c71a68 Fix integer rounding
The [docs](https://docs.python.org/3/library/functions.html#round)
specify that calling `round` with a negative precision removes
significant digits, so that `round(12345, -2) == 12300`. The
implementation was simply returning the original integer.

Additionally, `round(a, b)` is implemented as `(a / 10^b) * 10^b`, using
half-even rounding during the division.
2024-02-07 14:19:17 -05:00
Alin-Ioan Alexandru
3eda1cf3b4 Deprecation warning fix for __complex__ (#5152) 2024-01-25 14:54:06 +09:00
deantvv
6917b4c2ca os: ns_to_sec rounding (#5150)
In cpython, they use `_PyTime_ROUND_FLOOR` to read time.
But in RustPython, we use `[Duration::from_secs_f64](https://doc.rust-lang.org/std/time/struct.Duration.html#method.try_from_secs_f64)` to read time.

Therefore, RustPython isn't affected by the rounding issue in the way
that cpython does. We can safely ignore the `0.5*1e-9` bit in
`ns_to_sec` function.
2024-01-23 20:09:22 +09:00
kenny the :/
aaae566231 Raise error on power with negative number (#5143) 2024-01-12 21:16:53 +09:00
NakanoMiku
28f0fa48a4 Fix abc error messages (#5140)
Co-authored-by: Jeong, YunWon <jeong@youknowone.org>
2024-01-11 17:48:56 +09:00
NakanoMiku
de626b8627 Update test_file.py from CPython v3.12.0 2023-12-25 15:19:28 +08:00