16 Commits

Author SHA1 Message Date
Cosimo Lupo
4fb661f01a
cu2qu.test: load test package data using pkg_resources
The test suite is installed as a sub-package, so the test data must also be installed along with it.

The `__file__` attribute can be missing when importing a zipped package, so we load test files with `pkg_resources.resource_filename()`.
2016-11-02 17:51:08 +00:00
Cosimo Lupo
5e8f036edd
cu2qu_test: don't use 'random' to gen test curves for py23 compat, load from json file
`random.randint`, which is used in `cu2qu.benchmark.generate_curve` function, yields
different results when run in Python 2.7 or 3, despite using the same `random.seed(1)`.

For this reason, the `test_results_unchanged` and `test_results_unchanged_multiple` tests
in `cu2qu_test` module fail when run under Python 2.

Backward compatibility was broken with Python 3.2 `random` module, as a side effect of
fixing a non-uniformity bug. For mor info see:

https://groups.google.com/forum/#!topic/comp.lang.python/KwALjKjF6Y4
http://bugs.python.org/issue9025

To work around this, I dumped the result of generate_curve (running from Python 3.5.2 on
OSX) to a json file, and use that to run the tests.

I also stripped the white space to reduce the file size.

```python
import random
import json
from cu2qu.benchmark import generate_curve

random.seed(1)
curves = [generate_curve() for i in range(1000)]

with open("Lib/cu2qu/test/data/curves.json", "w") as fp:
    fp.write(json.dumps(curves).replace(" ", ""))
```

fixup
2016-11-02 17:51:07 +00:00
James Godfrey-Kittle
fc5f5d194d Fix tests 2016-08-01 14:15:26 -07:00
James Godfrey-Kittle
daaa1bd06f Report number of segments in result, not points (#41)
For some reason, I was subtracting 1 from the spline lengths in the
test report. Not sure why that is, so I've assumed it was wrong (and
now we subtract 2 to get the length in number of segments).
2016-08-01 14:08:26 -07:00
James Godfrey-Kittle
2a8eb7993e Revert "Change expected test results for travis"
This reverts commit 79beda96a4e26d5d1778f24de673cf14c6bda1ac.

Apparently now Travis expects what my local machine expects. I swear,
Travis is messing with me....
2016-07-27 17:02:44 -07:00
James Godfrey-Kittle
ea08338878 UFO benchmark module 2016-07-27 16:50:57 -07:00
James Godfrey-Kittle
79beda96a4 Change expected test results for travis
This is kind of annoying, because I don't get these results running
the test locally. Hoping it's a user error of some sort on my part.
2016-07-27 13:48:19 -07:00
James Godfrey-Kittle
d556e8a422 Update expected test results
These have changed with the new conversion method from
https://github.com/googlei18n/cu2qu/pull/33
2016-07-27 13:24:34 -07:00
James Godfrey-Kittle
039e35b212 No error returned from API, update tests 2016-07-27 13:21:47 -07:00
Behdad Esfahbod
79aaf25ae2 [test] Fix seed in class setup
Fixes https://github.com/googlei18n/cu2qu/issues/24
2016-04-30 17:59:50 +02:00
James Godfrey-Kittle
dc904ef31f Move root module tests to test/ directory 2016-04-21 11:32:36 -07:00
Cosimo Lupo
219efbc6f0 [test.utils] typo 2016-03-25 20:09:14 +01:00
Cosimo Lupo
a21c388355 [test.pens_test] add test module for Cu2Qu pens 2016-03-25 19:55:39 +01:00
Cosimo Lupo
5f8bb98107 [test.utils] add dummy pen and glyph classes to use with unit tests 2016-03-25 19:55:38 +01:00
Cosimo Lupo
2a6feb01be [test] add __init__.py to turn 'test' into a sub-package 2016-03-25 19:55:38 +01:00
Cosimo Lupo
072a60da97 create test folder; add test .glif files 2016-03-25 19:55:38 +01:00