From ffeaf788f090b10307247775b43dd7c0b0fd7342 Mon Sep 17 00:00:00 2001 From: ju5t Date: Thu, 1 Dec 2016 21:08:17 +0100 Subject: (#61) Add regex option to discover layer classes --- gerber/tests/test_layers.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gerber/tests') diff --git a/gerber/tests/test_layers.py b/gerber/tests/test_layers.py index 7e36dc2..6cafecf 100644 --- a/gerber/tests/test_layers.py +++ b/gerber/tests/test_layers.py @@ -48,6 +48,27 @@ def test_guess_layer_class(): for filename, layer_class in test_vectors: assert_equal(layer_class, guess_layer_class(filename)) +def test_guess_layer_class_regex(): + """ Test regular expressions for layer matching + """ + + # Add any specific test case (filename, layer_class) + test_vectors = [('test - top copper.gbr', 'top'), + ('test - copper top.gbr', 'top'), ] + + # Add custom regular expressions + layer_hints = [ + Hint(layer='top', + ext=[], + name=[], + regex=r'(.*)(\scopper top|\stop copper)$' + ), + ] + hints.extend(layer_hints) + + for filename, layer_class in test_vectors: + assert_equal(layer_class, guess_layer_class(filename)) + def test_sort_layers(): """ Test layer ordering -- cgit