Commit Graph

18 Commits

Author SHA1 Message Date
Shahar Naveh
f2765982cd Remove some tests from PLATFORM_INDEPENDENT_TESTS (#7459)
* Remove some platform dependent tests

* Mark failing tests
2026-03-18 21:55:56 +09:00
Jeong, YunWon
3b91466f62 Implement locale-aware 'n' format specifier for int, float, complex (#7350)
* Implement locale-aware 'n' format specifier for int, float, complex

Add LocaleInfo struct and locale-aware formatting methods to FormatSpec.
The 'n' format type now reads thousands_sep, decimal_point, and grouping
from C localeconv() and applies proper locale-based number grouping.
Remove @unittest.skip from test_format.test_locale.

* Fix complex 'n' format and remove locale expectedFailure markers

Rewrite format_complex_locale to reuse format_complex_re_im, matching
formatter_unicode.c: add_parens=0 and skip_re=0 for 'n' type.
Remove @expectedFailure from test_float__format__locale and
test_int__format__locale in test_types.py.

* Auto-format: cargo fmt --all

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-06 01:09:43 +09:00
ShaharNaveh
11ddf6e065 Mark failing tests 2026-03-01 10:42:37 +09:00
ShaharNaveh
9fad2c0b1d Update test_format.py from 3.14.3 2026-03-01 10:42:37 +09:00
yt2b
23a5c82a3a Add separator validation (#5904)
* Add separator validation

* Remove @unittest.expectedFailure
2025-07-06 23:08:07 +09:00
yt2b
0a59c1cad3 Implement PyComplex's __format__ function (#5900)
* Add num-complex in rustpython-common

* Implement PyComplex's __format__ function

* Remove @unittest.expectedFailure

* Fix PyComplex's __format__ function

* Remove @unittest.expectedFailure

* Add extra tests

* Rename to ZeroPadding and AlignmentFlag
2025-07-04 22:35:28 +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
ead42beff6 Disable test_locale in test_format.py
See https://github.com/RustPython/RustPython/issues/5181
2024-03-09 18:22:57 -05:00
Christopher Gambrell
d918f7e51b 'n' support for float format (#4865) 2023-04-16 00:06:20 +09:00
Andrey Maltsev
0674aa7d8f Update test_format.py from Cpython v3.11.2 2023-04-02 14:57:54 +00:00
Jim Fasarakis-Hilliard
2c2656dc7a Raise value error on large precision values for float, int __format__ (#3415) 2021-11-05 21:15:49 +02:00
Daniel Watkins
14b4f0092f cformat.rs: fix remaining test_format.test_common_format failures (#3405)
* cformat.rs: refactor fill_string to take fill_with_precision

This allows it to be used with both self.min_field_width and
self.precision, which is necessary for padding out %ds with precision.

* cformat.rs: zero-pad %d entries using precision

This matches CPython's behaviour.

* cformat.rs: don't left-adjust when filling with precision

That will always be prepending 0s to %d arguments, the LEFT_ADJUST flag
will be used by a later call to `fill_string` with the 0-filled string
as the `string` param.

* floats: handle alternate form of general formatting

* cformat.rs: convert width/precision to i32

In CPython, width can be isize but precision can only be i32.  Our
implementation currently assumes the same type for both: as CPython's
tests assert on overflows for precision, but not for width, we use that
size for both.

* test_format: run test_common_format

Except for the line which raises an OverflowError in CPython, because
overflows in Rust (and therefore RustPython) abort the process
immediately.

* test_types: don't expect test_float_to_string to fail

Its string formatting usage now works as expected.
2021-11-05 12:06:58 +02:00
Daniel Watkins
c5eba15370 test_format: run test_bytes_and_bytearray_format
All the errors have now been addressed.
2021-11-01 21:34:51 -04:00
Daniel Watkins
380653b6cb cformat.rs: implement %a correctly, using builtins::ascii
The repr() of Unicode strings is the Unicode string, so the previous
code was incorrect for that case (at least).
2021-11-01 21:34:51 -04:00
Padraic Fanning
2c665ff961 Mark erroring/failing tests 2021-02-21 11:31:52 -05:00
Padraic Fanning
aecc074cf2 Skip test for chewing up RAM 2021-02-21 11:31:51 -05:00
Padraic Fanning
e90491cc7d Add test_format from CPython 3.8.7 2021-02-21 11:31:51 -05:00