-
Notifications
You must be signed in to change notification settings - Fork 182
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
Move fixtures from test/test_dev.py file #1124
Move fixtures from test/test_dev.py file #1124
Conversation
@datapythonista take a look and see .This fails with an error |
Did you check what's the line that is failing? And the function being called there, and why it can return different number of values? Not sure what's the exact problem you're having, I guess when you face an error, you have a look at the problem yourself, and try to find a solution. Can you provide more information on what you tried, what exact part or line doesn't make sense... Also, if there is any relevant line you want to comment on in this PR, but it's not in the diff, you can add a temporary comment to it, so you can show relevant code in this PR. |
test/test_dev.py
Outdated
def basic_conf_with_subdir(tmpdir): | ||
return generate_basic_conf(tmpdir, 'some_subdir') | ||
|
||
|
||
def test_dev(capsys, basic_conf): | ||
tmpdir, local, conf = basic_conf |
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.
@datapythonista Thank you for your comment I created an issue #1130 that has more context on this,
I also read about it n noticed Unpacking works when the number of variables and the numbers of values is the same. am guessing for this particular case basic_conf
from conftest.py is returning more variables(return tmpdir, local, conf, machine_file) as seen below.This complains for all functions listed that requires unpacking
=========================== short test summary info ============================
FAILED test/test_check.py::test_check - ValueError: too many values to unpack...
FAILED test/test_dev.py::test_dev - ValueError: too many values to unpack (ex...
FAILED test/test_dev.py::test_dev_with_repo_subdir - ValueError: too many val...
FAILED test/test_dev.py::test_dev_strict - ValueError: too many values to unp...
FAILED test/test_dev.py::test_run_python_same - ValueError: too many values t...
FAILED test/test_dev.py::test_profile_python_same - ValueError: too many valu...
============ 6 failed, 194 passed, 16 skipped in 644.90s (0:10:44) =============
below is the conftest.py basic_conf
function being referenced
@pytest.fixture
def basic_conf(tmpdir, dummy_packages):
return generate_basic_conf(tmpdir)
and the generate_basic_conf function below;
def generate_basic_conf(tmpdir, repo_subdir='', values=dummy_values, dummy_packages=True):
tmpdir = str(tmpdir)
local = abspath(dirname(__file__))
os.chdir(tmpdir)
# Use relative paths on purpose since this is what will be in
# actual config files
shutil.copytree(os.path.join(local, 'benchmark'), 'benchmark')
machine_file = join(tmpdir, 'asv-machine.json')
shutil.copyfile(join(local, 'asv-machine.json'),
machine_file)
repo_path = tools.generate_test_repo(tmpdir, values,
subdir=repo_subdir).path
if dummy_packages:
matrix = {
"asv_dummy_test_package_1": [""],
"asv_dummy_test_package_2": tools.DUMMY2_VERSIONS,
}
else:
matrix = {}
conf_dict = {
'env_dir': 'env',
'benchmark_dir': 'benchmark',
'results_dir': 'results_workflow',
'html_dir': 'html',
'repo': relpath(repo_path),
'dvcs': 'git',
'project': 'asv',
'matrix': matrix,
}
if repo_subdir:
conf_dict['repo_subdir'] = repo_subdir
conf = config.Config.from_json(conf_dict)
if hasattr(sys, 'pypy_version_info'):
conf.pythons = ["pypy{0[0]}.{0[1]}".format(sys.version_info)]
return tmpdir, local, conf, machine_file
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.
Unpacking happens when you assign to a tuple, instead of a scalar, and the number of elements assigned and being assigned need to match. But please, instead of copying code, add a github comment to the relevant lines in the diff. And mention in the comment about the exact problem you're having. I'm not going to fix this error for you, and do the research on what's failing. That's your job. I'm happy to help you unblock in the specific part you can't understand yourself, but for that I need to know what it is.
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.
Thank you @datapythonista
|
||
|
||
def test_check(capsys, basic_conf): | ||
tmpdir, local, conf = basic_conf | ||
tmpdir, local, conf, _ = basic_conf |
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.
What's the reasoning here? Why do you think this is the best solution?
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.
Could have used * operator to pack the remaining elements into a list but since it was a single element remaining to be returned i decided to use _ the dummy variable to unpack it (as what was expected was 3 and the values returned on the left were 4 , the remaining element had no variable, i assigned a dummy variable _)
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.
Did you check why the function returns 4, and 3 are expected? My question is not about why underscore or star. The question is why if this used to return 3, why it now returns 4, and receiving one more parameter is your preferred solution (as opposed to make the function to keep returning 3, as it was before)?
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.
Yes,An extra variable machine_file was added to be returned that stores the hostname machine details. This makes the variables to be returned 4, and yet when the function was being called in different files earlier it was unpacking 3 variables, hence the need to add the dummy variable to match what the function is returning.
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.
I see. But this don't make sense. The reason why a different number of variables are being returned is because with your changes, a different function is being called. So different things are happening in the tests in your branch, and in master. Which is obviously something we don't want, unless you've got a reason to change the behavior, which doesn't seem it is the case.
Superseded by #1159 |
close #1030
close #1130