Skip to content

flesh out common code blocks in test/framework/options.py#2452

Merged
boegel merged 8 commits intoeasybuilders:developfrom
migueldiascosta:flesh_out_common_code_blocks
Mar 20, 2018
Merged

flesh out common code blocks in test/framework/options.py#2452
boegel merged 8 commits intoeasybuilders:developfrom
migueldiascosta:flesh_out_common_code_blocks

Conversation

@migueldiascosta
Copy link
Copy Markdown
Member

No description provided.

Comment thread test/framework/options.py
self.assertTrue(app.installdir.endswith('software/toy/0.0'))

def _assert_regexs(self, regexs, txt, assert_true=True):
for regex in regexs:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@migueldiascosta Please include a docstring when adding methods

Comment thread test/framework/options.py Outdated
else:
self.assertFalse(regex.search(txt), "Pattern '%s' NOT found in: %s" % (regex.pattern, txt))

def _run_mock_eb(self, args, stdout=True, stderr=False, do_build=False, raise_error=False, verbose=False, testing=False, strip=False):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@migueldiascosta Please include a docstring when adding methods

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why not always mock both stdout and stderr?

I would remove the stdout & stderr named arguments in this method, and always mock & return both?

@boegel boegel added this to the 3.6.0 milestone Mar 19, 2018
Comment thread test/framework/options.py
self.mock_stdout(False)
self.mock_stderr(False)
stdout, stderr = self._run_mock_eb(args, do_build=True, raise_error=True, verbose=True, strip=True)
self.assertEqual(stdout, '')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel this is failing, but I don't understand, why should stdout be empty?

It doesn't fail without the new helper method, so I must be missing something...

@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 20, 2018

@migueldiascosta testing is True by default in eb_main, but in your utility function _run_mock_eb it's set to False by defaut.

With testing=True, you don't get the "step" == lines printed to stdout.

So, you can fix this by using testing=True in your call to _run_mcok_ in test_force_download, I think.

@migueldiascosta
Copy link
Copy Markdown
Member Author

@boegel yes, I had noticed that just now, sorry about that :)

@migueldiascosta
Copy link
Copy Markdown
Member Author

inverting the default behaviour was not a brilliant idea...

@easybuilders easybuilders deleted a comment from boegelbot Mar 20, 2018
@easybuilders easybuilders deleted a comment from boegelbot Mar 20, 2018
@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 20, 2018

@migueldiascosta I agree, it's probably better to use testing=False as default in _run_mock_eb just like in eb_main to avoid confusion in the future as well?

@migueldiascosta
Copy link
Copy Markdown
Member Author

@boegel you mean testing=True by default, right? (it's already confusing :) ) - will do

@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 20, 2018

@migueldiascosta Yes, I just confirmed my own statement. I indeed mean testing=False in _run_mock_eb.

No True, I mean testing=True! ;-)

@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 20, 2018

Thanks for the effort @migueldiascosta!

@boegel boegel merged commit 0aba15e into easybuilders:develop Mar 20, 2018
MisterFruits pushed a commit to MisterFruits/easybuild-framework that referenced this pull request Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants