Skip to content

Commit ca1f32d

Browse files
committed
write a unit test and update configs
1 parent c01d3f7 commit ca1f32d

File tree

7 files changed

+64
-12
lines changed

7 files changed

+64
-12
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ Cargo.lock
44
*.pyc
55
build
66
*.so
7+
.eggs
8+
*.egg-info
9+
10+
# editor related
11+
.vscode

compile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from setuptools import setup
2+
from setuptools_rust import Binding, RustExtension
3+
4+
setup(name='py-sourcemap',
5+
version='0.1',
6+
rust_extensions=[RustExtension('py_sourcemap.py_sourcemap',
7+
'Cargo.toml', binding=Binding.PyO3)],
8+
packages=['py_sourcemap'],
9+
setup_requires=['setuptools_rust>=0.10.2'],
10+
# rust extensions are not zip safe, just like C-extensions.
11+
zip_safe=False
12+
)

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
from setuptools import setup
2-
from setuptools_rust import Binding, RustExtension
2+
from setuptools.command.install import install
33

4-
setup(name='py-sourcemap',
4+
class PostInstallCommand(install):
5+
"""Post-installation for installation mode."""
6+
def run(self):
7+
'''
8+
Write downloading process here
9+
mv target .so file into `py_sourcemap/py_sourcemap.so`
10+
'''
11+
install.run(self)
12+
13+
install_requires = []
14+
tests_require = install_requires + ['nose']
15+
16+
setup(
17+
name='py-sourcemap',
518
version='0.1',
6-
rust_extensions=[RustExtension('py_sourcemap.py_sourcemap',
7-
'Cargo.toml', binding=Binding.PyO3)],
819
packages=['py_sourcemap'],
20+
classifiers=[
21+
'Development Status :: 4 - Beta',
22+
'Environment :: Console',
23+
'Environment :: Web Environment',
24+
'Intended Audience :: Developers',
25+
'Operating System :: MacOS :: MacOS X',
26+
'Operating System :: Microsoft :: Windows',
27+
'Operating System :: POSIX',
28+
'Programming Language :: Python',
29+
'Programming Language :: Rust',
30+
],
31+
install_requires=install_requires,
32+
tests_require=tests_require,
33+
test_suite='nose.collector',
34+
cmdclass={
35+
'install': PostInstallCommand,
36+
},
937
# rust extensions are not zip safe, just like C-extensions.
1038
zip_safe=False
1139
)

tests/__init__.py

Whitespace-only changes.

tests/lookup.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/test_parse.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from unittest import TestCase
2+
3+
from py_sourcemap import SourcemapParser
4+
5+
6+
class TestParser(TestCase):
7+
def setUp(self):
8+
self.sourcemap = SourcemapParser("./tests/index.js.map")
9+
10+
def test_parse_trace(self):
11+
result = self.sourcemap.original_location_for(0, 195302)
12+
self.assertEqual(result[0], 22)
13+
self.assertEqual(result[1], 41)
14+
self.assertEqual(result[2][-13:], 'TopicList.jsx')
15+
self.assertEqual(result[3], 'edges')

0 commit comments

Comments
 (0)