Less of blog post and more of a reminder to myself. When using Flask and Unit Testing with Python, if either of the below errors occur (or something similar):

AttributeError: 'FlaskClientTestCase' object has no attribute 'client'

AttributeError: 'FlaskClientTestCase' object has no attribute 'app_context'

Then it may be because the setUp function of the test class has not set up correctly. Spent some time going round in circles until I realised that def setUp(self) of the class read def setup(self), and that lower case u really needed to be an upper case U for Unit Testing to use the function to set up the class.

The above Attribute Errors were generating as the class (FlaskClientTestCase) had failed to set up, so did not have a client attribute and did not have an app_context attribute.

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect