6 Commits

Author SHA1 Message Date
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
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
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