November 30, 2021

Testing Argparse Applications - the Better Way

When you are creating command line applications in Python, you probably heard of argparse, which is a great library for exactly doing this, and it is even included in Python’s standard library. Imagine you have created the following argparse application: <main.py> import argparse def main(): parser = argparse.ArgumentParser() parser.add_argument('--name', required=True) args = parser.parse_args() print(f'Hello {args.name}') if __name__ == '__main__': sys.exit(main()) Looks straightforward, works great, but at one point, you certainly want to add tests for it, right?...

November 21, 2021

Combine Coverage for Different Python Versions

Is it enough to run code coverage for a single Python version? Probably, but not necessarily. Especially when you still need to support Python 2.7 (sigh), there could be quite some different code paths for Python 2 and Python 3. A simple example… try: import Queue # Python 2 except ImportError: import queue as Queue # Python 3 But also the different Python 3 versions may require that you not only test your code for each interpreter, but also you need to assess code coverage for the different versions, and certainly you want to make sure you got all paths covered....

November 9, 2021

Bye-Bye python-memcached, hello pymemcache

For one app that I help maintaining I noticed that python-memcached was used, which has not been updated in several years. There were some efforts to transfer python-memcached to a new maintainer, but at the end that did not work out. So, the project is dead. While an unmaintained project may currently work, there are several things to consider: there may be bugs which do not get fixed there may be security issues which do not get fixed it may stop working for e....

November 5, 2021

Migrate a Repository From Bazaar to Git

Bazaar is a distributed version control system (VCS), developed by Canonical. For a long time, Bazaar was the only supported VCS on Launchpad. Launchpad is a code hosting platform, similar to the now prevalent GitHub, and while open to the public, nowadays it is mostly used by Canonical itself and many other individuals and companys to manage the whole lifecycle of creating packages for Ubuntu and its distributions. Since quite some time also git is a supported VCS on Launchpad....

July 22, 2021

GPG - All I Need to Know

While I need to use GPG pretty regularly, I always have to look up the commands - they just don’t stick :-) Over the last couple of months I collected every command I had to use. Enjoy! encrypt a file gpg --encrypt --recipient someone@example.com filename decrypt a file gpg --decrypt -outfile filename filename.gpg show all local keys gpg --list-keys search and add a new key gpg --keyserver keys.openpgp.org --search-key someone@example.com import a public key from the file system gpg --import key....

May 20, 2021

Enrich Test Coverage With Contexts

Hold on tight, now I expect a lot of us: We all test our code use coverage strive for 100% test coverage So, what’s missing? I miss some context 100% test coverage is great, but sometimes we need more information. e.g. which test covers line XXX? In sufficiently complex code bases, with mixed unit and integration tests, this is no longer easy to find out. Sure, you can set a breakpoint and run your tests and wait until the breakpoint has been hit....

May 12, 2021

Hugo and GitHub Pages - Welcome in the Land of Confusion

Yesterday, I migrated my blog to Hugo. GitHub Pages While the migration was straight forward, I was a bit puzzled with the deployment process to GitHub. For those who don’t know yet, GitHub enables all users to have an own website, called GitHub Pages, with a URL like https://your-user-name.github.io. Previously I used Lektor. The source code for my site lived in https://github.com/jugmac00/jugmac00.github.io.source, and was deployed by Lektor to https://github.com/jugmac00/jugmac00.github.io. Easy enough....

May 9, 2021

Bite My Shiny Type Annotated Library

How do you make type annotations available to the users of your library? Well, you just type annotate your library, right? No! But let’s step back for a moment. Flask 2.0 goes full type annotations This morning I read David Lord’s announcement that Flask, Jinja, Click, Werkzeug, MarkupSafe, and ItsDangerous are now fully type annotated, and new releases will be available next week. Ok, as I typed Flask-Reuploaded almost a year ago, I certainly noticed that Flask was not typed back then, but external type information was provided via typeshed, which I remember lively, as I had to add a missing type annotation for Werkzeug....

March 1, 2021

Testing the tox 4 Pre-Release at Scale

Every once in a while, you may read that one of your favorite used packages announces a new version. Sometimes even a so-called alpha version is announced. The maintainers then politely ask you, the user, to test the package, and give feedback if anything is broken. When the upcoming pytest version 6 had been announced, I wrote a short instruction on how to install pre-releases. This time, tox, the virtualenv management and test tool, announced a new version 4, but it is not just a new version, it is a complete rewrite by Bernát Gábor!...

October 30, 2020

Convincing an Enterprisy App to Work Behind nginx as Reverse Proxy

For simplicity, let’s the call the app Dated HR, a tool to “Simplify your HR work”, which offers support for time tracking, holiday, payroll… So far so good, and even better, as it is an enterprisy Windows software, which needs to be configured with IIS and a MSSQL database, a colleague of mine installed it on an internal Windows server. The app makes a web GUI available under http://nemesis.company.local, which would work like a charm - for our colleagues at site, but not for the colleagues from the other sites....