Commit aa1c29c3 authored by FichteFoll's avatar FichteFoll

Update tests

Now use unittest for better error indication. This will effectively show where the lists differ instead of just throwing an "AssertError" and also only requires to read the file only once.
In that process also update to Python 3.3.
parent bef12fae
language: python
python:
- "2.7"
- "3.3"
#command to run tests
script: nosetests
import json
import unittest
from collections import OrderedDict
def test_json_is_valid():
fp = open("repositories.json")
json.load(fp)
# Only run these using `notetests` (or `python -m unittest`) from the root directory
def test_repositories_in_order():
j = json.load(open("repositories.json"))
repos = j['repositories'][3:]
assert repos == sorted(repos, key=unicode.lower)
def test_package_names_in_order():
j = json.load(open("repositories.json"), object_pairs_hook=OrderedDict)
packages = j['package_name_map'].keys()
assert packages == sorted(packages, key=unicode.lower)
# No need to check for this because all the other tests would fail anyway
# class TestValidity(unittest.TestCase):
# def test_json_is_valid(self):
# fp = open("repositories.json")
# json.load(fp)
def test_renamed_packages_in_order():
j = json.load(open("repositories.json"), object_pairs_hook=OrderedDict)
packages = j['renamed_packages'].keys()
assert packages == sorted(packages, key=unicode.lower)
class TestOrder(unittest.TestCase):
# Do not limit the list comparison to 600 chars (for more detailed debugging)
maxDiff = None
def setUp(self):
self.j = json.load(open("repositories.json"), object_pairs_hook=OrderedDict)
def test_repositories_in_order(self):
repos = self.j['repositories']
# Remove "https://github.com/SublimeText" at the top because it is purposely not in order
del repos[0]
self.assertEqual(repos, sorted(repos, key=str.lower))
def test_package_names_in_order(self):
map_packages = list(self.j['package_name_map'].keys())
self.assertEqual(map_packages, sorted(map_packages, key=str.lower))
def test_renamed_packages_in_order(self):
ren_packages = list(self.j['renamed_packages'].keys())
self.assertEqual(ren_packages, sorted(ren_packages, key=str.lower))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment