<commit_before>import os
import zipfile
from datetime import date, time
from django.test import TestCase, override_settings
from . import ie


FIXTURES_DIR = './busstops/management/tests/fixtures/'


class IrelandTest(TestCase):
    """Tests some timetables generated directly from XML files"""

    def setUp(self):
        self.dir_path = os.path.join(FIXTURES_DIR, 'google_transit_mortons')
        with zipfile.ZipFile(self.dir_path + '.zip', 'a') as open_zipfile:
            for item in os.listdir(self.dir_path):
                open_zipfile.write(os.path.join(self.dir_path, item), item)

    def tearDown(self):
        os.remove(self.dir_path + '.zip')

    @override_settings(DATA_DIR=FIXTURES_DIR)
    def test_small_timetable(self):
        timetable = ie.get_timetable('mortons-20-165-y11', date(2017, 6, 7))[0]
        self.assertEqual(str(timetable.groupings[0]), 'Merrion, Merlyn Park - Citywest, Castle House')
        self.assertEqual(str(timetable.groupings[1]), 'Citywest, Castle House - Ballsbridge, Ailesbury Road')
        self.assertEqual(timetable.groupings[0].rows[0].times, [time(7, 45)])
        self.assertEqual(timetable.groupings[0].rows[4].times, [time(7, 52)])
        self.assertEqual(timetable.groupings[0].rows[6].times, [time(8, 1)])
        self.assertEqual(timetable.groupings[1].rows[0].times, [time(17, 20)])
        self.assertEqual(timetable.groupings[1].rows[6].times, [time(17, 45)])
        self.assertEqual(timetable.groupings[1].rows[-1].times, [time(18, 25)])
        self.assertEqual(len(timetable.groupings[0].rows), 18)
        self.assertEqual(len(timetable.groupings[1].rows), 14)<commit_msg>Fix Python 2.7 test<commit_after>import os
import zipfile
from datetime import date, time
from django.test import TestCase, override_settings
from . import ie


FIXTURES_DIR = './busstops/management/tests/fixtures/'


class IrelandTest(TestCase):
    """Tests some timetables generated directly from XML files"""

    def setUp(self):
        self.dir_path = os.path.join(FIXTURES_DIR, 'google_transit_mortons')
        with zipfile.ZipFile(self.dir_path + '.zip', 'a') as open_zipfile:
            for item in os.listdir(self.dir_path):
                open_zipfile.write(os.path.join(self.dir_path, item), item)

    def tearDown(self):
        os.remove(self.dir_path + '.zip')

    @override_settings(DATA_DIR=FIXTURES_DIR)
    def test_small_timetable(self):
        timetable = ie.get_timetable('mortons-20-165-y11', date(2017, 6, 7))[0]
        timetable.groupings.sort(key=lambda g: g.rows[0].times[0])
        self.assertEqual(str(timetable.groupings[0]), 'Merrion, Merlyn Park - Citywest, Castle House')
        self.assertEqual(str(timetable.groupings[1]), 'Citywest, Castle House - Ballsbridge, Ailesbury Road')
        self.assertEqual(timetable.groupings[0].rows[0].times, [time(7, 45)])
        self.assertEqual(timetable.groupings[0].rows[4].times, [time(7, 52)])
        self.assertEqual(timetable.groupings[0].rows[6].times, [time(8, 1)])
        self.assertEqual(timetable.groupings[1].rows[0].times, [time(17, 20)])
        self.assertEqual(timetable.groupings[1].rows[6].times, [time(17, 45)])
        self.assertEqual(timetable.groupings[1].rows[-1].times, [time(18, 25)])
        self.assertEqual(len(timetable.groupings[0].rows), 18)
        self.assertEqual(len(timetable.groupings[1].rows), 14)
{'fraction_non_alphanumeric': 0.1482031482031482, 'fraction_numerical': 0.033264033264033266, 'mean_word_length': 3.9096209912536444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6764194', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1111, 'n_words': 195}