| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
(the code is ready for review I believe, keeping as draft because I need to update the docs) |
Sorry, something went wrong.
|
(py35 failures might be related to #7303) |
Sorry, something went wrong.
|
|
||
| Initialization: determining rootdir and inifile | ||
| ----------------------------------------------- | ||
| Initialization: determining rootdir and configfile |
There was a problem hiding this comment.
do we want to preserve external links to this target?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't really think it is necessary... we've changed section titles in the past. Or is there a way to preserve the old link that I'm not aware of?
Sorry, something went wrong.
There was a problem hiding this comment.
Left some comments on the code. I've yet to read to issue to try to understand the ini_options approach but I get a sense of why it was done...
Sorry, something went wrong.
|
|
||
| result = config.get("tool", {}).get("pytest", {}).get("ini_options", None) | ||
| if result is not None: | ||
| # convert all scalar values to strings for compatibility with other ini formats |
There was a problem hiding this comment.
Should this be recursive? Otherwise I can write e.g. addopts = [true, 10].
Sorry, something went wrong.
There was a problem hiding this comment.
I don't think so, that's invalid in TOML:
>>> import toml
>>> toml.loads('x = [true, 10]')
...
ValueError: Not a homogeneous array
>>> toml.loads('x = [10, 20]')
{'x': [10, 20]}Recursive arrays are a possibility:
>>> toml.loads('x = [[10, 20], [30, 40]]')
{'x': [[10, 20], [30, 40]]}But I would rather be safe here and convert them to string anyway, because that's what we would have gotten if we wrote that in an ini file.
Sorry, something went wrong.
| # convert all scalar values to strings for compatibility with other ini formats | ||
| # conversion to actual useful values is made by Config._getini | ||
| def make_scalar(v): | ||
| return v if isinstance(v, (list, tuple)) else str(v) |
There was a problem hiding this comment.
Does toml actually give out both list and tuple? Would have assumed it's only one.
What about dicts?
dates and datetimes can also be unexpected, but I guess their str is fine.
Sorry, something went wrong.
There was a problem hiding this comment.
You are right, fixed to only test for lists.
Everything else should be converted to strings I think, because that's what we would have gotten if we wrote them in an ini file. The tool.pytest.ini_options is a bridge to configure pytest using pyproject.toml files with the legacy options, hopefully we can in the future thinks of better ways to make advantage of the more powerful features of TOML.
Sorry, something went wrong.
|
|
||
| def _get_ini_config_from_pyproject_toml( | ||
| path: py.path.local, | ||
| ) -> Optional[Dict[str, Any]]: |
There was a problem hiding this comment.
Basically IIUC we want the Any here to be Union[None, str, List[str]].
Sorry, something went wrong.
There was a problem hiding this comment.
I've changed to Union[str, List[str]], because I don't think TOML supports None?
Sorry, something went wrong.
| return None | ||
|
|
||
|
|
||
| def getcfg(args): |
There was a problem hiding this comment.
Would be great if you're able to type-annotate this one 😁 Usually I don't ask this but in this case I think it can really be beneficial for clarifying things.
Sorry, something went wrong.
There was a problem hiding this comment.
No worries, feel free to ask anytime... but I just did it, and yikes!
def getcfg(args: List[Union[str, py.path.local]]) -> Tuple[Optional[py.path.local], Optional[py.path.local], Optional[Dict[str, Union[str, List[str]]]]]:Feel free to suggest how to improve readability here.
Sorry, something went wrong.
There was a problem hiding this comment.
I gave it a go there, let me know if you have any suggestions however. 👍
Sorry, something went wrong.
There was a problem hiding this comment.
'
Sorry, something went wrong.
|
Noticed also -c is not being handled correctly yet. Will need a bit more of time to work out the kinks. |
Sorry, something went wrong.
This makes it clear each type of file that it is supported. Also dropped 'config' parameter as it is no longer used.
While setup.cfg might be considered an "inifile", "pyproject.toml" definitely is not.
|
Rebased and did further refactorings in findpaths.py to be able to make -c somefile.toml to work. |
Sorry, something went wrong.
There was a problem hiding this comment.
Great work @nicoddemus, besides adding the new feature, the code in findpaths.py is much cleaner than before.
I agree that the approach taken is a decent way to support pyproject.toml in the midterm without too many consequences for the future or big code changes.
Personally I'd prefer "tool.pytest.ini" over "tool.pytest.ini_options".
I'd also add a short "note" comment in the documentation to explain why it's "pytest.tool.ini_options" and not just "tool.pytest" -- it's seems odd if unexplained.
There's also some type errors that come up when checking with proper py.path.local typing (pytest-dev/py#232), but there are also existing errors so I need to take care of that myself anyway.
Sorry, something went wrong.
This function no longer seems to be necessary
Done! |
Sorry, something went wrong.
|
@nicoddemus Re. my comment above
Not sure if you missed it or rejected it (which is fine of course). Just seems to me the _options part is redundant. |
Sorry, something went wrong.
|
Hi @bluetech Oh sorry, didn't mean to seem dismissive, I thought you had seen this comment: #7247 (comment) That's what we had agreed on the original issue. 😁 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix #1556