import os
from .main import main


def test_main():
    _this_path = os.path.dirname(os.path.realpath(__file__))
    for (in_file, time_direction) in [('right', 90),
                                      ('up', 0),
                                      ('down', 180)]:
        in_file_name = os.path.join(_this_path, 'test', '{0}.txt'.format(in_file))
        ref_file_name = os.path.join(_this_path, 'test', '{0}.svg'.format(in_file))
        svg = main(1.0, in_file_name, time_direction)
        with open(ref_file_name, 'r') as f:
            reference = f.read()
            assert svg in reference, "failed to test {0}".format(in_file)

@@ -44,16 +44,83 @@
 _main():
+%0A%0A    generate_references = os.getenv('GENERATE_REFERENCES', False)
 %0A    _th
@@ -173,16 +173,17 @@
 ile__))%0A
+%0A
     for 
@@ -551,16 +551,125 @@
 ection)%0A
+        if generate_references:%0A            with open(ref_file_name, 'w') as f:%0A                f.write(svg)%0A
         
@@ -760,18 +760,18 @@
 ert svg 
-in
+==
  referen

make it easy to generate new references