-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove python2 six functionality #1072
Remove python2 six functionality #1072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Just the raise thing is breaking the CI, and doesn't seem correct, you can simply use raise
, and if the CI is green, happy to merge after that.
asv/util.py
Outdated
@@ -8,6 +8,7 @@ | |||
import datetime | |||
import json | |||
import math | |||
from msilib.schema import Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what is this, but I don't think we want it.
asv/util.py
Outdated
@@ -1192,7 +1189,7 @@ def _remove_readonly(func, path, exc_info): | |||
pass | |||
|
|||
# Reraise original error | |||
six.reraise(*exc_info) | |||
raise Error(*exc_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise Error(*exc_info) | |
raise |
Thanks for the suggestions @datapythonista |
You've got few errors you'll have to take a look at. |
test/test_console.py
Outdated
@@ -21,53 +18,39 @@ def check_write(value, expected, stream_encoding, preferred_encoding): | |||
locale.getpreferredencoding = lambda: preferred_encoding | |||
|
|||
# Check writing to io.StringIO | |||
if six.PY3: | |||
stream = io.StringIO() | |||
_write_with_fallback(value, stream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I clean out PY2 lines this part breaks with the traceback below; What could i be missing?
def check_write(value, expected, stream_encoding, preferred_encoding):
old_getpreferredencoding = locale.getpreferredencoding
try:
locale.getpreferredencoding = lambda: preferred_encoding
# Check writing to io.StringIO
if six.PY3:
stream = io.StringIO()
with pytest.raises(TypeError):
> _write_with_fallback(value, stream)
E Failed: DID NOT RAISE <class 'TypeError'>
test/test_console.py:27: Failed
============================================ short test summary info ============================================
FAILED test/test_console.py::test_write_with_fallback - Failed: DID NOT RAISE <class 'TypeError'>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange. Can you undo the specific changes that are causing the failure for now? Or if it's easier, just move the whole file with your changes to a new PR, and remove it from here. This way we can merge and forget what's working, and we can focus better on what's not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ,let me do this
asv/commands/quickstart.py
Outdated
@@ -51,7 +48,7 @@ def run(cls, dest=".", top_level=None): | |||
color_print("(2) benchmark suite in a separate repository") | |||
color_print("") | |||
while True: | |||
answer = raw_input("Layout to use? [1/2] ") | |||
answer = input("Layout to use? [1/2] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I change this function from python 2 raw_input() to input() I get this error. What am I doing wrong?
def test_quickstart(tmpdir):
tmpdir = str(tmpdir)
dest = join(tmpdir, 'separate')
os.makedirs(dest)
tools.run_asv('quickstart', '--no-top-level', '--dest', dest)
assert isfile(join(dest, 'asv.conf.json'))
assert isfile(join(dest, 'benchmarks', 'benchmarks.py'))
conf = util.load_json(join(dest, 'asv.conf.json'), js_comments=True)
assert 'env_dir' not in conf
assert 'html_dir' not in conf
assert 'results_dir' not in conf
dest = join(tmpdir, 'same')
os.makedirs(dest)
try:
asv.commands.quickstart.raw_input = lambda msg: '1'
> tools.run_asv('quickstart', '--dest', dest)
test/test_quickstart.py:30:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/tools.py:148: in run_asv
return args.func(args, **kwargs)
asv/commands/quickstart.py:40: in run_from_args
return cls.run(dest=args.dest, top_level=args.top_level)
asv/commands/quickstart.py:54: in run
answer = input("Layout to use? [1/2] ")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.capture.DontReadFromInput object at 0x7f622daa2eb0>, args = ()
def read(self, *args):
> raise OSError(
"pytest: reading from stdin while output is captured! Consider using `-s`."
)
E OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
../../../.local/lib/python3.8/site-packages/_pytest/capture.py:192: OSError
--------------------------------------------- Captured stdout call ----------------------------------------------
· Setting up new Airspeed Velocity benchmark suite.
· Edit asv.conf.json to get started.
· Setting up new Airspeed Velocity benchmark suite.
Which of the following template layouts to use:
(1) benchmark suite at the top level of the project repository
(2) benchmark suite in a separate repository
Layout to use? [1/2]
============================================ short test summary info ============================================
FAILED test/test_quickstart.py::test_quickstart - OSError: pytest: reading from stdin while output is captured...
=============================================== 1 failed in 1.01s ===============================================
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but same as for the other, do you mind splitting this to its own PR please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
Really nice @dorothykiz1, good job here |
xref #1040
This will remove six functionality in the following files;