Re: How to detect an undefined method?
On 03/04/2022 02.28, anthony.flury wrote: > On 27/03/2022 15:59, dn wrote: > >> What is code coverage? >> In the simplest words, code coverage is a measure of exhaustiveness of a >> test suite. 100% code coverage means that a system is fully tested. > > Sorry, but that is a gross over-simplification. Please be careful how you trim messages/quote previous posts. Above gives an incorrect impression and attribution! The original text: « The following article includes both pros and cons of using coverage.py: How to use code coverage in Python with pytest? April 11, 2021 Sebastian python, testing software Basics What is code coverage? In the simplest words, code coverage is a measure of exhaustiveness of a test suite. 100% code coverage means that a system is fully tested. ... https://breadcrumbscollector.tech/how-to-use-code-coverage-in-python-with-pytest/ » Readers will be able to come to their own conclusions - which may very-well mirror your own. Another consideration is the context of the OP and the problem he was trying to solve. -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Exchange OWA using Python?
On 2022-04-01, Christian Gollwitzer wrote: > Am 01.04.22 um 01:26 schrieb Grant Edwards: >> On 2022-03-31, Christian Gollwitzer wrote: >>> Davmail is written in Java, not Python, but basically this should >>> not matter if you only use it. >> >> Have you used it with OWA as the protocol? > > At least I thought so - this was in 2016 - 2017 and there was external > webmail access allowed to our mail server. I've used davmail to connect > to it. I vaguely remember that there was one day a sudden change, > webmail was disabled and davmail then connected using EWS. Maybe the OWA > protocol also evolved, I now see it on the roadmap. It was probably at least 5 years ago when EWS got disabled and I couldn't get davmail to work any longer. It could be that davmail does support the OWA "API" now. I spent some more time browsing the davmail web site, and couldn't really find a clear statement one way or the other. > Good that you found a solution now with owl! It's taken some tweaking to get Thunderbird "adjusted". The Exchange server does some stupid tricks like adding marketing stuff to all messages before they're sent externally. The logic it uses to decide _where_ to insert that stuff isn't very good, and Thunderbird's default reply attribution line causes the marketing "footer" to be inserted at the top of the message. And if you're not careful about reply formatting, Outlook will decide to hide the entire message (a trick it uses to try to compensate for the brain-dead practice of replying on top and including a copy of all previous e-mails in the conversation (that way email disk storage is O(N^2) instead of O(N)) I also didn't like the appearance of quoted text in replies from Thunderbird, so I'm working on an extension to add some CSS to make quoted text look more like it does with other e-mail clients (with a "quote bar" on the left). Surprisingly, Thunderbird also lacks any sort of system-tray support. There's an add-on app that's supposed to do that, but I haven't tried it yet... > I'm having a similar issue at my current position, we're using Lotus > Notes (yes! The package from the 90s, it's outright horrible). Everybody I've ever known who has used Notes hated it. One wonders why it continues to be used... > There is only one thing available, the iNotes exporter, which allows > to read the mail using thunderbird, sending is not > implemented. Always keeping fingers crossed that the IT department > does not update the server protocol. Sometimes they do minor changes > like internal redirection URL changes, which costs me half a day to > fix then. I know how that goes. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: How to detect an undefined method?
On 27/03/2022 15:59, dn wrote: What is code coverage? In the simplest words, code coverage is a measure of exhaustiveness of a test suite. 100% code coverage means that a system is fully tested. Sorry, but that is a gross over-simplification. 100% coverage means that you have tested all of the branches in a given module, or a given class; it absolutely does not mean it is fully tested. For example I can write code and unit-test cases for a trivial piece of code, and to achieve 100% coverage, but for the code to still fail on invalid input data, or for the code to fail due to exceptions from library code that my code doesn't handle. To claim to be fully tested a piece of code has to be exercised against *every* possible input and *every* single possible event from *every* single source - that alone makes 100% testing impossible. If you think logically about it, you can only test a very small fraction of all possible test cases; the key is to pick those cases which represent a good range of possible inputs and events (including both valid and invalid data, exceptions, errors etc). At best 100% coverage measure means that every branch through the code has been executed at least once by your test cases. It doesn't prove that your test cases are complete, or that your code takes into account all possible occurrences - 100% coverage doesn't mean it is fully tested. In terms of coverage, achieving 100% coverage is a laudable target, but it is often either unachievable or not worth the effort; aiming to achieve a high value (say > 80%) is sensible target. If you achieve your high coverage count by doing black-box testing (ie. by testing to the specification of code and thinking what can right and what can go wrong), then the coverage is a more useful measure - if you write your unit-tests by looking at the code, then all that a high measurement means is that you are able (mostly) to read and understand your own code. -- Anthony Flury *Moble*: +44 07743 282707 *Home*: +44 (0)1206 391294 *email*: anthony.fl...@btinternet.com -- https://mail.python.org/mailman/listinfo/python-list
flask app convert sql query to python plotly.
i would like to convert in my flask app an SQL query to an plotly pie chart using pandas. this is my code : def query_tickets_status() : query_result = pd.read_sql (""" SELECT COUNT(*)count_status, status FROM tickets GROUP BY status""", con = mydc_db) return query_result labels_statut = query_tickets_status['status'] values_statut = query_tickets_status['count_status'] fig = go.Figure(data=[go.Pie(labels=labels_statut, values=values_statut)]) graphSuppliers = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder) return render_template('admin/dashboard.html', graphSuppliers = graphSuppliers) this is my template file. Your Plotly Chart var graphs = {{graphSuppliers | safe}}; Plotly.plot('chart',graphs,{}); but I get this error : TypeError: 'function' object is not subscriptable -- https://mail.python.org/mailman/listinfo/python-list
Re: flask app convert sql query to python plotly
Abdellah ALAOUI ISMAILI wrote: def query_tickets_status() : query_result = pd.read_sql (""" SELECT COUNT(*)count_status, status FROM tickets GROUP BY status""", con = mydc_db) return query_result labels_statut = query_tickets_status['status'] labels_statut = query_tickets_status()['status'] -- https://mail.python.org/mailman/listinfo/python-list
dict.get_deep()
A proposal. Very often dict are used as a deeply nested carrier of data, usually decoded from JSON. Sometimes I needed to get some of this data, something like this: data["users"][0]["address"]["street"] What about something like this instead? data.get_deep("users", 0, "address", "street") and also, instead of this try: result = data["users"][0]["address"]["street"] except KeyError, IndexError: result = "second star" write this: data.get_deep("users", 0, "address", "street", default="second star") ? -- https://mail.python.org/mailman/listinfo/python-list