Skip to content

Commit

Permalink
First simple test.
Browse files Browse the repository at this point in the history
  • Loading branch information
henu committed Sep 7, 2020
1 parent f7a5291 commit 2c067ea
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
/.cache/
/build/
/bigjson.egg-info/
/dist/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ with open('wikidata-latest-all.json', 'rb') as f:
print element['type']
print element['id']
```


Testing
=======

```
pytest .
```
Empty file added tests/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from io import BytesIO
from unittest import TestCase

import bigjson


JSON_FILE = b"""
{
"string": "blah",
"number": 123,
"true": true,
"false": false,
"null": null,
"array": [1, 2, 3],
"object": {
"x": "y"
}
}
"""


class TestBasics(TestCase):

def test_basics(self):
file = BytesIO(JSON_FILE)
data = bigjson.load(file)

self.assertEqual(len(data), 7)
self.assertEqual(data['string'], 'blah')
self.assertEqual(data['number'], 123)
self.assertEqual(data['true'], True)
self.assertEqual(data['false'], False)
self.assertEqual(data['null'], None)
self.assertEqual(len(data['array']), 3)
self.assertEqual(len(data['object']), 1)
self.assertEqual(data['object']['x'], 'y')

0 comments on commit 2c067ea

Please sign in to comment.