question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for boolean pattern

See original GitHub issue

Hi!

Would it possible to have support for boolean pattern? such as true or false converts it to boolean in a step pattern?

For instance:

@given("This is {condition:B}")
def example(step, condition:bool):
    pass

I am more than willing to implement this if this is an acceptable feature!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
SamuelYvoncommented, Jun 21, 2017

Actually, in Python 3 it doesn’t:

bool(‘true’) True bool(‘false’) True

Hmm well then, I have some buggy code somewhere then!

If it really is what you need I think I’ll merge a PR with the custom type - which still leaves the question what it should interpret: true, false, True, False, 0, 1, yes or no etc. ?

I would really only go for true TRUE True false FALSE False , really, any variants of true and false.

And I agree about the custom parser, but writing a custom parser for all the variants where we want to check a situation with a binary outcome to have it closer to English is a little tedious, it’s nothing impossible it’s just gonna be a lot of troubles and a source of bugs that we don’t really need.

I’ll be making a PR in the next days!

1reaction
rscrimojrcommented, Jun 21, 2017

You should add on and off while you are at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How boolean Type Work in XML with Examples - eduCBA
XML boolean type is an XSD Simple Data types that represent True or False or Yes / No values as their types and...
Read more >
xs:boolean - XML Schema [Book] - O'Reilly
Name xs:boolean — Boolean (true or false). Derived from: xs:anySimpleType Primary: xs:boolean Known subtypes: none Facets: xs:pattern, xs:whiteSpace ...
Read more >
How to use patterns to specify variable type as Boolean (True ...
What is important though is, that I want x to be a real number, and y to be a boolean variable, such that...
Read more >
To use a Geometry Pattern in Boolean Operations - PTC Support
Click Boolean Operations. The Boolean Operations tab opens. 2. Under Operation, click Merge.
Read more >
Boolean data type in Python - GeeksforGeeks
The Boolean and operator returns False if any one of the inputs is False else returns True. A, B, A and B. True,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found