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.

Pony ORM lambda or generator expression function is marked as unexecuted

See original GitHub issue

Hi, Here a small matter I have with ponyorm. In ponyorm you can make query to database with lambda or generator expressions. those 2 thing are equivalent :

return Praticien.select(lambda p: p.nom_d_exercice.lower().startswith(chaine.lower()))
return select(p for p in Praticien if p.nom_d_exercice.lower().startswith(chaine.lower()))

html report says :port says :

The line 98 didn't finish lmabda on line 98 or lne 98 didn't run generator expression in line 98

seems that smaller expression are ok :

Praticien.select()

I really would help to try fix it but I do not know where to start

Thank you Jimmy

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nedbatcommented, Nov 29, 2018

Some other possibilities of how to handle this more gracefully:

  1. You can set the coverage.py pragma regex so that some lines are automatically pragma’d:

    [report]
    partial_branches = 
        pragma: no branch
        \.select\(lambda
    

    Now any line that matches either of the two regexes will be considered partial-branch, so your line is recognized even without a comment.

  2. You can separate the definition of the lambda or generator expression from the line that uses them:

    to_select = lambda p: p.nom_d_exercice.lower().startswith(chaine.lower())    # pragma: no branch
    return Praticien.select(to_select)
    

    or:

    to_delete = (j for j in MyEntityClass if j.deleted == True)  # pragma: no branch
    delete(to_delete)
    

    This isolates the non-run code to its own line, so you don’t run the risk of turning off coverage measurement on a line that truly needs it.

0reactions
JaDoggcommented, Nov 29, 2018

Hello,

See this: https://stackoverflow.com/questions/53280985/how-to-ignore-ponyorm-generator-expressions-in-nose-tests-coverage/53281148#53281148

I’ve tried to solve is with #pragma: no branch, it works some time. but some time you need to also use #pragma: no coverage

Read more comments on GitHub >

github_iconTop Results From Across the Web

Queries — Pony ORM documentation
Pony allows to use generator expressions as a very natural way of writing database queries. Pony provides select() function which accepts Python generator, ......
Read more >
ponyORM: trouble with query - python - Stack Overflow
I have query with dynamic conditions,i.e. select (lambda obj:obj.A = ...
Read more >
the 2 of 3 and 4 0 5 to 6 a 7 in 8 1 9 for 10 image 11 2 12 is 13
... 877 traffic 878 five 879 function 880 michigan 881 power 882 professional ... 1604 host 1605 pollution 1606 multiple 1607 mark 1608...
Read more >
librispeech-vocab.txt - OpenSLR
... CHECK CHECK'D CHECK'S CHECKBOOK CHECKED CHECKER CHECKERBERRIES CHECKERBERRY ... EXPRESSE EXPRESSED EXPRESSES EXPRESSETH EXPRESSIBLE EXPRESSIN EXPRESSING ...
Read more >
Untitled
Phut cuoi che linh karaoke, Latin music fest chicago, Unexecuted bench ... Nh178l! 2 organ systems and their functions, Tangadan falls cliff diving, ......
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