Exercise: Custom Asserts
coming... for Workroom PlayTime 036
We'll use LLMs to help us build custom asserts. You'll use your own access to an LLM, and we'll work in instances of a pre-set-up Github Codespace environment with a JavaScript test harness, a Python test harness, and code which could do with a custom assert or two.
We'll look at the tiny systems, identify what would help, ask LLMs to build working asserts, see what they give back, and compare notes.
Also to come: a page on custom asserts
Environment
I've built something that has all the code, test harnesses and plumbing for you to try this in JavaScript and Python. You'll access your own copy of that environment via VisualStudio Code in your browser.
For these exercises, we'll try out Github Codespaces. You may need a github acount.
Go to the Custom Asserts repo , and you should see a readme page β click on the "open in Github Codespaces" button and wait. Further instructions are in the readme β once you're in, you'll need to run something on the commandline to install all the infrastructure dependencies, and more to run tests. You can browse the software under test while the dependencies are being installed.
As of today (29 Oct), the environment is working, with one JS example. I'm building out a second, and Python equivalents of both. It'll be done by the workshop.
Infrastructure
The tests for my JavaScript examples here use Chai (assertion library) and Mocha (unit test framework). My Python examples use bare Python and pyTest (unit test framework).
You'll need to go to your own LLM to ask for code β you'll find examples below.
Python and assertion libraries
Assertion libraries seem not as prevalent in the Python community as Chai and others are in the JS community.
Perhaps that is because it is simple and common to build custom asserts directly in Python. Pytest leans heavily on Pythonβs own assert and has a hook pytest_assertrepr_compare for detailed messages.
Python does have assertion libraries β pyHamcrest being the standout example.
Comments
Sign in or become a Workroom Productions member to read and leave comments.