Skip to content

Commit

Permalink
Merge branch 'main' into go-test-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjinkun committed Jan 25, 2021
2 parents b575340 + 3925685 commit 8ad4f6e
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
pipenv run lint
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
pipenv run lint-warn
- name: Test with nosetests
- name: Test with unittest
run: |
pipenv run test
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.5.9
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ setuptools = ">=30.3.0"
setuptools-scm = "*"
wheel = "*"
autopep8 = "*"
nose = "*"
importlib-metadata = "*"
responses = "*"

Expand All @@ -19,7 +18,7 @@ launchable = {editable = true,path = "."}
[scripts]
build = "python setup.py sdist bdist_wheel"
install = "pip install -U ."
test = "python -m nose tests"
test = "python -m unittest"
lint = "flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics"
lint-warn = "flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics"
format = "autopep8 -ivr ."
2 changes: 1 addition & 1 deletion launchable/commands/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def compare_java_version(output: str) -> int:

def check_java_version(javacmd: str) -> int:
"""Check if the Java version meets what we need. returns >=0 if we meet the requirement"""
v = subprocess.run([javacmd,"-version"], check=True, capture_output=True, text=True)
v = subprocess.run([javacmd,"-version"], check=True, stderr=subprocess.PIPE, universal_newlines=True)
return compare_java_version(v.stderr)

@click.command(name="verify")
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ install_requires =
requests
junitparser>=1.6.3
setuptools
tests_requires =
nose
python_requires = >=3.4

[options.entry_points]
console_scripts = launchable = launchable.__main__:main

[options.package_data]
launchable = jar/exe_deploy.jar

[nosetests]
exe = True
tests = tests
62 changes: 32 additions & 30 deletions tests/commands/test_verify.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
from nose.tools import eq_
from unittest import TestCase
from launchable.commands.verify import *

def test_compare_version():
def sign(x):
if x<0:
return -1
if x>0:
return 1
return 0

def f(expected, a,b):
"""Ensure symmetry on two sides"""
eq_(sign(compare_version(a,b)), expected)
eq_(sign(compare_version(b,a)), -expected)
class VersionTest(TestCase):
def test_compare_version(self):
def sign(x):
if x<0:
return -1
if x>0:
return 1
return 0

f(0, [1, 1, 0], [1, 1]) # 1.1.0 = 1.1
f(1, [1, 1], [1, 0]) # 1.1 > 1.0
f(1, [1, 0, 1], [1]) # 1.0.1 > 1
def f(expected, a,b):
"""Ensure symmetry on two sides"""
self.assertEqual(sign(compare_version(a,b)), expected)
self.assertEqual(sign(compare_version(b,a)), -expected)

def test_java_version():
assert compare_java_version(
"""
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
"""
) >= 0
f(0, [1, 1, 0], [1, 1]) # 1.1.0 = 1.1
f(1, [1, 1], [1, 0]) # 1.1 > 1.0
f(1, [1, 0, 1], [1]) # 1.0.1 > 1

assert compare_java_version(
"""
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
"""
) < 0
def test_java_version(self):
self.assertTrue(compare_java_version(
"""
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
"""
) >= 0)

self.assertTrue(compare_java_version(
"""
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
"""
) < 0)
13 changes: 7 additions & 6 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from click.testing import CliRunner
from launchable.__main__ import main
from launchable.version import __version__
from nose.tools import eq_
from unittest import TestCase


def test_version():
runner = CliRunner()
result = runner.invoke(main, ['--version'])
eq_(result.exit_code, 0)
eq_(result.output, 'launchable-cli, version {}\n'.format(__version__))
class VersionTest(TestCase):
def test_version(self):
runner = CliRunner()
result = runner.invoke(main, ['--version'])
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, 'launchable-cli, version {}\n'.format(__version__))
15 changes: 8 additions & 7 deletions tests/utils/test_gzipgen.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from launchable.utils.gzipgen import compress
from nose.tools import eq_
import gzip
from unittest import TestCase

def test_compress():
"""Basic sanity test of """
encoded=b''.join(compress([b'Hello',b' ',b'world']))
msg = gzip.decompress(encoded)
print(msg)
eq_(msg,b'Hello world')
class GzippenTest(TestCase):
def test_compress(self):
"""Basic sanity test of """
encoded=b''.join(compress([b'Hello',b' ',b'world']))
msg = gzip.decompress(encoded)
print(msg)
self.assertEqual(msg, b'Hello world')

0 comments on commit 8ad4f6e

Please sign in to comment.