Fails the test because of the quote style.
See original GitHub issueI have simple wrapper function to the US census library:
def state_info(state):
"""
Given a the full name of a state, returns the corresponding abbreviation and FIPS code.
Example:
>>> state_info("texas")
("TX", "48")
"""
abbrev = states.mapping("name", "abbr").get(state.title())
st = states.lookup(abbrev)
fips = st.fips
return (abbrev, fips)
However xdoctest
fails because the of quoting style:
DOCTEST PART BREAKDOWN
Failed Part:
2 >>> state_info("texas")
DOCTEST TRACEBACK
Expected:
("TX", "48")
Got:
('TX', '48')
Repr Difference:
got = "('TX', '48')"
want = '("TX", "48")'
Since the expected value matches my output, I thought the test would pass.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Uplifting Quotes For Those Who Failed the Bar Exam
If you failed the bar exam, we feel for you! ... We believe something as simple as a quote can reveal how important...
Read more >Quotation Marks and Direct Quotations - University of Sussex
The use of quotation marks, also called inverted commas, is very slightly complicated by the fact that there are two types: single quotes...
Read more >You Can Quote Me on This - APA Style 6th Edition Blog
Formatting the quotation is more than just an arbitrary means of ensuring consistency. It serves as a flag to the readers, telling them...
Read more >Titles of Books, Plays, Articles, etc.: Underline? Italics ...
Names of websites are not generally italicized or enclosed in quotation marks, because they are usually made into Internet links that result in...
Read more >What should I do with a quote found by the check? - Scribbr
If the quote contains 40 words or more, format it as a block quote, which begins on a new line and is indented...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW, the style of the expected “want” string isn’t enforced by black, and it would be more accurate to use the quoting style there that the actual Python interpreter outputs. Also, there is nothing stopping you from simply writing:
And that has the advantage that it can be refactored as a unit test verbatim. The other alternative - if you simply want this for more documentation purposes, is to remove the check entirely and rely on unit tests to actually check cases:
But if you want to extend the checker, all of the logic lives here:
https://github.com/Erotemic/xdoctest/blob/main/src/xdoctest/checker.py
It probably also makes sense to add a directive:
https://github.com/Erotemic/xdoctest/blob/main/src/xdoctest/directive.py
which is disabled by default (maybe call it
NORMALIZE_QUOTES
?) and can be specified to enable this behavior.Thank you very much! I did use the first alternative you suggested and it worked like a charm. 👍