Comments (12)
Looks like it's due to urwid:
In [1]: import locale
In [2]: locale.getlocale()
Out[2]: (None, None)
In [3]: import urwid
In [4]: locale.getlocale()
Out[4]: ('en_GB', 'UTF-8')
from pytest-pudb.
As it seems to me it was a really rare case of this bug. So I think it's kind of optional.
from pytest-pudb.
@massich it doesn't seem to be pytest-pudb
problem, but the machine locale problem. %B
should be the full name of a month in current locale.
I'd like to ask you to attach the result of these commands run into you virtual environment:
$ python -c "import locale; print(locale.getlocale())"
$ python -c "import datetime; print(datetime.datetime.strftime(datetime.datetime.now(), '%B'))"
from pytest-pudb.
the answer is the same for both:
$ conda create -n test pytest && source activate test
(test) $ python -c "import locale; print(locale.getlocale())"
('en_US', 'UTF-8')
(test) $ python -c "import datetime; print(datetime.datetime.strftime(datetime.datetime.now(), '%B'))"
July
(test) $ pytest test_datetime.py
================================= test session starts =================================
platform linux -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /tmp, inifile:
collected 1 item s
test_datetime.py .
============================== 1 passed in 0.01 seconds ===============================
(test) $ pip install pytest-pudb
(test+pytest-pudb) $ python -c "import locale; print(locale.getlocale())"('en_US', 'UTF-8')
('en_US', 'UTF-8')
(test+pytest-pudb) $ python -c "import datetime; print(datetime.datetime.strftime(datetime.datetime.now(), '%B'))"
July
(test+pytest-pudb) $ pytest test_datetime.py================================= test session starts =================================
platform linux -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /tmp, inifile:
plugins: pudb-0.5
collected 1 item s
test_datetime.py F
====================================== FAILURES =======================================
____________________________________ test_strptime ____________________________________
def test_strptime():
import datetime
> datetime.datetime.strptime('29-April-2013', "%d-%B-%Y")
test_datetime.py:3:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/sik/miniconda3/envs/test/lib/python3.6/_strptime.py:565: in _strptime_datetime
tt, fraction = _strptime(data_string, format)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data_string = '29-April-2013', format = '%d-%B-%Y'
def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
"""Return a 2-tuple consisting of a time struct and an int containing
the number of microseconds based on the input string and the
format string."""
for index, arg in enumerate([data_string, format]):
if not isinstance(arg, str):
msg = "strptime() argument {} must be str, not {}"
raise TypeError(msg.format(index, type(arg)))
global _TimeRE_cache, _regex_cache
with _cache_lock:
locale_time = _TimeRE_cache.locale_time
if (_getlang() != locale_time.lang or
time.tzname != locale_time.tzname or
time.daylight != locale_time.daylight):
_TimeRE_cache = TimeRE()
_regex_cache.clear()
locale_time = _TimeRE_cache.locale_time
if len(_regex_cache) > _CACHE_MAX_SIZE:
_regex_cache.clear()
format_regex = _regex_cache.get(format)
if not format_regex:
try:
format_regex = _TimeRE_cache.compile(format)
# KeyError raised when a bad format is found; can be specified as
# \\, in which case it was a stray % but with a space after it
except KeyError as err:
bad_directive = err.args[0]
if bad_directive == "\\":
bad_directive = "%"
del err
raise ValueError("'%s' is a bad directive in format '%s'" %
(bad_directive, format)) from None
# IndexError only occurs when the format string is "%"
except IndexError:
raise ValueError("stray %% in format '%s'" % format) from None
_regex_cache[format] = format_regex
found = format_regex.match(data_string)
if not found:
raise ValueError("time data %r does not match format %r" %
> (data_string, format))
E ValueError: time data '29-April-2013' does not match format '%d-%B-%Y'
/home/sik/miniconda3/envs/test/lib/python3.6/_strptime.py:362: ValueError
============================== 1 failed in 0.08 seconds ===============================
from pytest-pudb.
Just for completness, This might be related.
from pytest-pudb.
It looks like importing pytest_pudb has a side effect of setting the locale:
In [1]: import locale
In [2]: locale.getlocale()
Out[2]: (None, None)
In [3]: import pudb
In [4]: locale.getlocale()
Out[4]: (None, None)
In [5]: import pytest
In [6]: locale.getlocale()
Out[6]: (None, None)
In [7]: import pytest_pudb
In [8]: locale.getlocale()
Out[8]: ('en_GB', 'UTF-8')
from pytest-pudb.
Hey,
I've just fixed this problem in urwid/urwid#279 in locale-fix
branch. Can someone confirm that it fixes this issue?
from pytest-pudb.
Update: fix is in master now.
from pytest-pudb.
@and3rson thanks, it looks good to me now:
In [1]: import locale
In [2]: locale.getlocale()
Out[2]: (None, None)
In [3]: import pytest_pudb
In [4]: locale.getlocale()
Out[4]: (None, None)
from pytest-pudb.
I think this issue can be closed now :)
from pytest-pudb.
Thanks =)
from pytest-pudb.
@wronglink Perhaps setup.py should specify a minimum urwid version that includes the fix?
from pytest-pudb.
Related Issues (12)
- Implement the pudb.b module
- Allow opening pudb not just on errors HOT 2
- Latest Pytest release (3.3.1) breaks pytest-pudb HOT 1
- Support pu.db
- TypeError in PuDBInvoke when using pytest --capture=no HOT 1
- Look at __tracebackhide__
- tagging releases
- Support pudb external breakpoint file HOT 7
- Add unittests
- PyPI package for v0.4 is broken HOT 1
- Avoid tearDown and cleanup in post mortem debugging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-pudb.