mirror of https://github.com/flaggo/pydu.git
add repr to cmd.chcp
This commit is contained in:
parent
0b0a0ba2f7
commit
22703bbebf
|
@ -73,6 +73,7 @@ if WINDOWS:
|
|||
"""
|
||||
def __init__(self, code):
|
||||
self.origin_code = windll.kernel32.GetConsoleOutputCP()
|
||||
self.code = code
|
||||
windll.kernel32.SetConsoleOutputCP(code)
|
||||
|
||||
def __enter__(self):
|
||||
|
@ -80,3 +81,6 @@ if WINDOWS:
|
|||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
windll.kernel32.SetConsoleOutputCP(self.origin_code)
|
||||
|
||||
def __repr__(self):
|
||||
return '<active code page number: {}>'.format(self.code)
|
||||
|
|
|
@ -37,7 +37,8 @@ def test_chcp():
|
|||
assert windll.kernel32.GetConsoleOutputCP() == origin_code
|
||||
|
||||
try:
|
||||
chcp(437)
|
||||
cp = chcp(437)
|
||||
assert windll.kernel32.GetConsoleOutputCP() == 437
|
||||
assert str(cp) == '<active code page number: 437>'
|
||||
finally:
|
||||
windll.kernel32.SetConsoleOutputCP(origin_code)
|
||||
|
|
Loading…
Reference in New Issue