Home

Awesome

tg_pytest

Python-based TinyG tester for v8 and g2core code bases. The tester runs JSON test files and reports results. This project is maintained in the WingIDE Python but can use any Python environment.

Please note: tg_pytest is only intended to get the easy tests done; It is not intended to be a full-featured test framework. It is not suited to running continuous tests, i.e. running a Gcode file and looking for the ongoing results. It's a batch tester, not streaming.

How It works

Usage

Test Sequence - What should happen when RUN:

JSON test files:

Tests / Test JSON:

JSON Elements

Note that strings in embedded JSON do not need to be escaped, as TinyG will always accept JSON in relaxed mode, regardless of whether it's set to relaxed or strict JSON mode. (The board must be in strict mode so all responses will be strict, of course). The shortcuts also work, like t for true or n for null. The following example still produces valid JSON but is easier to edit and maintain:

{
  "t":{"label":"Read axis configuration",
     "send":["{\"x\":null}"]}      ...can be sent as:
}

{
  "t":{"label":"Read axis configuration",
     "send":["{x:n}"]}
}

Another trick is to "comment out" a line in a JSON file just invalidate the tag by putting XXX_ or some other characters (but not #) in front of it. The tag/value will be ignored by the tester.

Before and After

Additional JSON objects can be provided in a file that will run before and after tests. The JSON format is the same as the t object, but only the listed tags are recognized. before_each will run prior to local before, and after_each will run following local after in a given test object.

Inline Delays in Send Objects

It's possible to add a delay between strings in a send array. For example: <br> "send":["m3 m7 m8", "G1 F500 X30", "del 0.25", "!"]<br> ...inserts a 250 ms delay before the bang. The space before the value is required.

Defaults

A defaults JSON object can be included in a test file. Defaults are read and applied in the location they are found in the file, so it's good to list these first, or sometimes after the before_all. The default settings will be applied to all subsequent tests. Local, per-test settings for the same variables will override the defaults. Values supported include:

Notes on Running Tests

Known Limitations and Open Issues:

Changes

TODO list