Comments (2)
It's actually pretty consistent, just not in the intuitive way. Allure renders a description as markdown. Here are several examples:
Paragraph
In your first example the docstring is just a line of text. It's rendered as a paragraph:
Python:
def test_1():
"""First description"""
Docstring value:
First description
Rendered description:
Block code
The second example has a docstring consisting of three lines. The first and the last lines are essentially empty and are ignored. The second line is prepended by four spaces, hence is rendered as a block code:
Python:
def test_2():
"""
Second description
"""
Docstring value:
Second description
Rendered description:
Complex description
Now, as you see how it works, it's easy to put something even more complicated into the docstring.
Python:
def test_3():
"""The next line will appear as a block code:
This is rendered as a block code.
This is a table:
| Name | ID |
| ---- | --- |
| John | 1 |
| Jane | 2 |
"""
Docstring value:
The next line will appear as a block code:
This is rendered as a block code.
This is a table:
| Name | ID |
| ---- | --- |
| John | 1 |
| Jane | 2 |
Rendered description:
So it's pretty consistent. It's just that raw markdown isn't that convenient to be put in python docstrings. As you see, it makes docstrings quite ugly.
I think we may try to dedent docstrings before putting them to the test's description, so that the third example could be written like this:
def test_3():
"""
The next line will appear as a block code:
This is rendered as a block code.
This is a table:
| Name | ID |
| ---- | --- |
| John | 1 |
| Jane | 2 |
"""
That will help making the whole thing more predictable and user-friendly.
from allure-python.
I think we may try to dedent docstrings before putting them to the test's description
@delatrie Please do! I've been working w/ Allure for several months now and it was nagging at me that we couldn't have formatted text from the docstring, never imagining I needed to dedent! Don't remember seeing this info in any documentation.
Dedenting in code is quite counter-intuitive and doesn't really follow Python aesthetics. Also, some linters like black
auto-indent (ie, insert indentation), which makes use of these linters harder or impossible (black
doesn't have an option to not indent docstrings).
Dendenting in Allure, like you suggested, would be the way to go.
from allure-python.
Related Issues (20)
- parametrized test in allure testops in different cases HOT 1
- Question - is it possible call allure generation from python code HOT 1
- FEATURES BY STORIES is missing
- Add ability to add parametr to name of paramerised test case HOT 1
- When the version of behave is v1.2.7.dev5, an error will appear when running using allure_behave as the report formatter. HOT 1
- allure-pytest 2.13.2 will merge parameterized use cases HOT 2
- Allure does not handle --last-failed on parametrized tests
- Precondition and expected results decorators
- Add dynamic.label and dynamic.title support to allure-behave HOT 1
- Get "KeyError: None" On While Exwcuting with Pytest Command with Generating Allure Report HOT 3
- using pytest.mark.parametrize will miss some testcase in report HOT 1
- i have facing issues AttributeError: module 'allure' has no attribute 'severity_level' HOT 1
- If the step combines strong and soft checks, then the step is marked as pass despite soft checks failed
- allure 和 pytest.mark 不应该混淆
- tms link pattern missing in behave
- [Feature] Pytest - Rename @allure.testcase decorator to @allure.tms HOT 1
- Suites view - failed Playwright pytest tests are not shown under their corresponding suite/sub-suite HOT 1
- Package view for behave tests - The class label isn't displayed in the tree
- Allow users to actually take advantage of passed categories via message regex.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allure-python.