clear-code / pikzie Goto Github PK
View Code? Open in Web Editor NEWPikzie is a Unit Testing Framework for Python. Pikzie's interface is easy to write and easy to debug your code.
Home Page: https://github.com/clear-code/pikzie
Pikzie is a Unit Testing Framework for Python. Pikzie's interface is easy to write and easy to debug your code.
Home Page: https://github.com/clear-code/pikzie
python2.7.9でpip経由でインストールしようとするとエラーがでます。
環境としては、anyenvの下にpyenvを入れ、virtualenvを使っています。
出力は
$ pip install Pikzie
You are using pip version 7.0.0, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting Pikzie
Downloading pikzie-1.0.1.tar.gz (75kB)
100% |████████████████████████████████| 77kB 2.5MB/s
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/Pikzie.egg-info
writing pip-egg-info/Pikzie.egg-info/PKG-INFO
writing top-level names to pip-egg-info/Pikzie.egg-info/top_level.txt
writing dependency_links to pip-egg-info/Pikzie.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/Pikzie.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/Pikzie.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/Pikzie.egg-info/SOURCES.txt'
Usage: -c [options] [test_files]
-c: error: no such option: --egg-base
Exception KeyError: KeyError(140735219213056,) in <module 'threading' from '/Users/yasudayousuke/.anyenv/envs/pyenv/versions/2.7.9/lib/python2.7/threading.pyc'> ignored
----------------------------------------
Command "python setup.py egg_info" failed with error code 2 in /private/var/folders/xr/kqmdknms0k34y6xt2ykmh7hc0000gn/T/pip-build-tH_IoW/Pikzie
になります。
$ python setup.py install
を使うとインストールできます。
When I run run-test.py
with --version
to show pikzie
version number, but it does not show version easily.
Show version of pikzie
.
$ ./run-test.py --version
1.0.1
I used run-test.py
file which is same as sample of run-test.py
in README files:
#!/usr/bin/env python
import sys
import os
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, os.path.join(base_dir, "lib"))
sys.path.insert(0, base_dir)
import pikzie
sys.exit(pikzie.Tester().run())
I tried following command to show pikzie
version:
$ ./run-test.py --version
Usage: run-test.py [options] [test_files]
run-test.py: error: no such option: --version
I found how to show except result that pikzie shows pikzie value.
How did I found it in test/run-test.py file.
#!/usr/bin/env python
import sys
import os
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, os.path.join(base_dir, "lib"))
sys.path.insert(0, base_dir)
import pikzie
sys.exit(pikzie.Tester(version=pikzie.version).run())
And I tried following command to show pikzie
version and it seems successfully:
$ ./run-test.py --version
1.0.1
I think this way is not kind because user does not change pikzie
version by myself.
So, vesion
variable should be fixed by pikzie
development team.
次のメールを送信する。
To: [email protected]
Cc: [email protected]
Subject: Subscribe
subscribe
Some Pythonic testing frameworks (like unittest
or pytest
) allow users to
express exception-related conditions through "with" blocks. For example,
with unittest
, we can check if a non-existent key raises KeyError as:
def test_deleted_item(self):
with self.assertRaises(KeyError):
self.table.get_item('deleted')
Below is the equivalent example using pytest
:
def test_deleted_item(table):
with pytest.raises(KeyError):
table.get_item('deleted')
Now, I'm trying to add the same functionality to pikzie. Here is a patch:
Implement a context manager for exception-related testing [#30]
What do you think about this feature or patch? Any feedback is welcome.
python3.4でこのテストが失敗します
出力
1) Failure: TestAssertions.test_assert_open_file: ["test_assert_open_file"])
/Users/yasudayousuke/oss_hack/pikzie/test/test_assertions.py:604: ["test_assert_open_file"])
expected: <(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') succeeds\n but was: <<class 'OSError'>>([Errno 2] No such file or directory: '/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])>
but was: <(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') succeeds\n but was: <<class 'FileNotFoundError'>>([Errno 2] No such file or directory: '/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])>
diff:
- (False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') succeeds\n but was: <<class 'OSError'>>([Errno 2] No such file or directory: '/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])
? ^^
+ (False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') succeeds\n but was: <<class 'FileNotFoundError'>>([Errno 2] No such file or directory: '/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])
? ^^^^^^^^^^^^
folded diff:
(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expec
ted: open('/Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') succeeds\n
- but was: <<class 'OSError'>>([Errno 2] No such file or directory: '/Users/yasu
? ^^ ----------
+ but was: <<class 'FileNotFoundError'>>([Errno 2] No such file or directory: '/
? ^^^^^^^^^^^^
- dayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])
+ Users/yasudayousuke/oss_hack/pikzie/test/nonexistent') is raised", None]])
? ++++++++++
IOErrorをFileNotFoundErrorに変更するとテストは通り、原因はわかったのですが、2系との互換を維持する方法がわかりませんでした。
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError
self.assert_result(False, 1, 2, 1, 0, 0, 0, 0,
[('F',
"TestCase.test_assert_open_file",
"expected: open('%s') succeeds\n"
" but was: <%s>(%s) is raised" % \
(nonexistent_path,
FileNotFoundError,
"[Errno 2] No such file or directory: '%s'" % \
nonexistent_path),
None)],
["test_assert_open_file"])
というコードも試してみましたが、最初と同じエラーが出力されました。
reStructuredTextでは箇条書きするときにインデントしてはいけないけど、しちゃっているので引用扱いになってしまっている。
README.ja.rstも同様。
From reading pikzie/core.py, Pikzie seems to support the 'abort the
test execution with CTRL-C' feature (as other testing frameworks do).
However, the problem is that it does not work well right now.
In fact, hitting CTRL-C while testing reveals that the testing process
just continues the execution of test cases, and won't exit.
These pull-requests below are my attempt to address this issue:
With these patches applied, the keybord interruption will work nicely.
python2.7と3.4で,pikzieのディレクトリにrun-test.pyを行うと挙動が変化する.
python2.7ではfailureが発生しないが,
python3.4ではfailureが4件発生する.
python2.7
python3.4
$ git clone https://github.com/clear-code/pikzie.git
$ cd pikzie
$ python2.7 test/run-test.py
..................P..O.........................................
1) Pending: TestAssertions.test_assert_search_syslog_call: can't read /var/log/messages.
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:561: self.pend("can't read /var/log/messages.")
2) Omission: TestAssertions.test_kernel_symbol: only for Linux environment
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:619: self.omit("only for Linux environment")
Finished in 0.279 seconds
63 test(s), 93 assertion(s), 0 failure(s), 0 error(s), 1 pending(s), 1 omission(s), 0 notification(s)
$ git clone https://github.com/clear-code/pikzie.git
$ cd pikzie
$ python3.4 test/run-test.py
..............FF..P..O.......................F.....F...........
1) Failure: TestAssertions.test_assert_open_file: ["test_assert_open_file"])
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:600: ["test_assert_open_file"])
expected: <(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') succeeds\n but was: <<class 'OSError'>>([Errno 2] No such file or directory: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') is raised", None]])>
but was: <(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') succeeds\n but was: <<class 'FileNotFoundError'>>([Errno 2] No such file or directory: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') is raised", None]])>
diff:
- (False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') succeeds\n but was: <<class 'OSError'>>([Errno 2] No such file or directory: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') is raised", None]])
? ^^
+ (False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expected: open('/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') succeeds\n but was: <<class 'FileNotFoundError'>>([Errno 2] No such file or directory: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') is raised", None]])
? ^^^^^^^^^^^^
folded diff:
(False, (1, 2, 1, 0, 0, 0, 0), [['F', 'TestCase.test_assert_open_file', "expec
ted: open('/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexisten
- t') succeeds\n but was: <<class 'OSError'>>([Errno 2] No such file or director
? ^^ ----------
+ t') succeeds\n but was: <<class 'FileNotFoundError'>>([Errno 2] No such file o
? ^^^^^^^^^^^^
- y: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexistent') is
? ----------
+ r directory: '/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/nonexis
? ++++++++++
- raised", None]])
+ tent') is raised", None]])
? ++++++++++
2) Failure: TestAssertions.test_assert_raise_call: "test_assert_raise_call_instance"])
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:508: "test_assert_raise_call_instance"])
expected: <(False, (3, 8, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', "expected: <<class 'NameError'>> is raised\n but was: test_assertions.nothing_raised() nothing raised", None], ['F', 'TestCase.test_assert_raise_call_different_error', "expected: <<class 'NameError'>> is raised\n but was: <<class 'ZeroDivisionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_raise_call_instance', "expected: <ComparableError('not error',)>\n but was: <ComparableError('raise error',)>", None]])>
but was: <(False, (3, 6, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', 'expected: <"global name \'unknown_name\' is not defined">\n but was: <"name \'unknown_name\' is not defined">', None], ['F', 'TestCase.test_assert_raise_call_different_error', "expected: <<class 'NameError'>> is raised\n but was: <<class 'ZeroDivisionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_raise_call_instance', "expected: <ComparableError('not error',)>\n but was: <ComparableError('raise error',)>", None]])>
diff:
- (False, (3, 8, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', "expected: <<class 'NameError'>> is raised\n but was: test_assertions.nothing_raised() nothing raised", None], ['F', 'TestCase.test_assert_raise_call_different_error', "expected: <<class 'NameError'>> is raised\n but was: <<class 'ZeroDivisionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_raise_call_instance', "expected: <ComparableError('not error',)>\n but was: <ComparableError('raise error',)>", None]])
? ^^ ^ ^^^^^^^^ ------------------------------------------------------------------------------------
+ (False, (3, 6, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', 'expected: <"global name \'unknown_name\' is not defined">\n but was: <"name \'unknown_name\' is not defined">', None], ['F', 'TestCase.test_assert_raise_call_different_error', "expected: <<class 'NameError'>> is raised\n but was: <<class 'ZeroDivisionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_raise_call_instance', "expected: <ComparableError('not error',)>\n but was: <ComparableError('raise error',)>", None]])
? ^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
folded diff:
- (False, (3, 8, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', "expe
? ^ ^
+ (False, (3, 6, 3, 0, 0, 0, 0), [['F', 'TestCase.test_assert_raise_call', 'expe
? ^ ^
- cted: <<class 'NameError'>> is raised\n but was: test_assertions.nothing_raise
+ cted: <"global name \'unknown_name\' is not defined">\n but was: <"name \'unkn
- d() nothing raised", None], ['F', 'TestCase.test_assert_raise_call_different_e
? ^^^ ^ ------ ---------
+ own_name\' is not defined">', None], ['F', 'TestCase.test_assert_raise_call_di
? ^^^^^^^^^^^^^ ^^^^ ++
- rror', "expected: <<class 'NameError'>> is raised\n but was: <<class 'ZeroDivi
? ---------
+ fferent_error', "expected: <<class 'NameError'>> is raised\n but was: <<class
? +++++++++
- sionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_raise_call
? ---------
+ 'ZeroDivisionError'>>(division by zero)", None], ['F', 'TestCase.test_assert_r
? +++++++++
- _instance', "expected: <ComparableError('not error',)>\n but was: <ComparableE
? ---------
+ aise_call_instance', "expected: <ComparableError('not error',)>\n but was: <Co
? +++++++++
- rror('raise error',)>", None]])
+ mparableError('raise error',)>", None]])
? +++++++++
3) Pending: TestAssertions.test_assert_search_syslog_call: can't read /var/log/messages.
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:561: self.pend("can't read /var/log/messages.")
4) Omission: TestAssertions.test_kernel_symbol: only for Linux environment
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_assertions.py:619: self.omit("only for Linux environment")
5) Failure: TestRunner.test_metadata: self.assert_output("EF", 2, 0, 1, 1, 0, 0, 0, details, tests)
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:118: self.assert_output("EF", 2, 0, 1, 1, 0, 0, 0, details, tests)
expected: <('EF\n'
'\n'
'1) Error: TestCase.test_error_raised\n'
' bug: 123\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:84: '
'self.unknown_attribute\n'
"<class 'AttributeError'>: 'TestCase' object has no attribute "
"'unknown_attribute'\n"
'\n'
'2) Failure: TestCase.test_with_metadata: self.assert_equal(3, 1 - 2)\n'
' bug: 999\n'
' key: value\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:89: '
'self.assert_equal(3, 1 - 2)\n'
'expected: <3>\n'
' but was: <-1>\n'
'\n'
'Finished in 0.000 seconds\n'
'\n'
'2 test(s), 0 assertion(s), 1 failure(s), 1 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')>
but was: <('EF\n'
'\n'
'1) Error: TestCase.test_error_raised\n'
' bug: 123\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:84: '
'self.unknown_attribute\n'
"<class 'AttributeError'>: 'TestCase' object has no attribute "
"'unknown_attribute'\n"
'\n'
'2) Failure: TestCase.test_with_metadata: self.assert_equal(3, 1 - 2)\n'
' key: value\n'
' bug: 999\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:89: '
'self.assert_equal(3, 1 - 2)\n'
'expected: <3>\n'
' but was: <-1>\n'
'\n'
'Finished in 0.000 seconds\n'
'\n'
'2 test(s), 0 assertion(s), 1 failure(s), 1 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')>
diff:
('EF\n'
'\n'
'1) Error: TestCase.test_error_raised\n'
' bug: 123\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:84: '
'self.unknown_attribute\n'
"<class 'AttributeError'>: 'TestCase' object has no attribute "
"'unknown_attribute'\n"
'\n'
'2) Failure: TestCase.test_with_metadata: self.assert_equal(3, 1 - 2)\n'
+ ' key: value\n'
' bug: 999\n'
- ' key: value\n'
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:89: '
'self.assert_equal(3, 1 - 2)\n'
'expected: <3>\n'
' but was: <-1>\n'
'\n'
'Finished in 0.000 seconds\n'
'\n'
'2 test(s), 0 assertion(s), 1 failure(s), 1 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')
6) Failure: TestRunner.test_run_failed_dict_data: self.assert_output("F", 1, 1, 1, 0, 0, 0, 0, details, [test])
/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:234: self.assert_output("F", 1, 1, 1, 0, 0, 0, 0, details, [test])
expected: <('F\n'
'\n'
'1) Failure: TestCase.test_fail_assertion_dict_data (fail): '
'self.assert_equal("dict", data)\n'
" data: {'b': 2, 'a': 1}\n"
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:218: '
'self.assert_equal("dict", data)\n'
"expected: <'dict'>\n"
" but was: <{'b': 2, 'a': 1}>\n"
'\n'
'Finished in 0.000 seconds\n'
'\n'
'1 test(s), 1 assertion(s), 1 failure(s), 0 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')>
but was: <('F\n'
'\n'
'1) Failure: TestCase.test_fail_assertion_dict_data (fail): '
'self.assert_equal("dict", data)\n'
" data: {'b': 2, 'a': 1}\n"
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:218: '
'self.assert_equal("dict", data)\n'
"expected: <'dict'>\n"
" but was: <{'a': 1, 'b': 2}>\n"
'\n'
'Finished in 0.000 seconds\n'
'\n'
'1 test(s), 1 assertion(s), 1 failure(s), 0 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')>
diff:
('F\n'
'\n'
'1) Failure: TestCase.test_fail_assertion_dict_data (fail): '
'self.assert_equal("dict", data)\n'
" data: {'b': 2, 'a': 1}\n"
'/Users/shopetan/b3/springAB/sezemi/2015_0627/pikzie/test/test_runner.py:218: '
'self.assert_equal("dict", data)\n'
"expected: <'dict'>\n"
- " but was: <{'b': 2, 'a': 1}>\n"
? --------
+ " but was: <{'a': 1, 'b': 2}>\n"
? ++++++++
'\n'
'Finished in 0.000 seconds\n'
'\n'
'1 test(s), 1 assertion(s), 1 failure(s), 0 error(s), 0 pending(s), 0 '
'omission(s), 0 notification(s)\n')
Finished in 0.278 seconds
63 test(s), 89 assertion(s), 4 failure(s), 0 error(s), 1 pending(s), 1 omission(s), 0 notification(s)
https://github.com/kabayan55/pikzie/blob/master/README.ja
上記のページ(README.ja)の「オプション」の項目を読んで、テスト実行時にオプションを適用しようと思ったのですが、その方法がわかりませんでした。
python --priority run-test.py
と実行した結果、
Unknown option: --
usage: /usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
と出力されました。
例えば、
python run-test.py [option]
と書いてあれば、間違えずに実行ができると思います。
テストの実行を試みたのですが、実行できませんでした。
https://github.com/kabayan55/pikzie/blob/master/README.ja
上記ページ(README.ja)の「使い方」の項目を読み、run-test.pyを作成しました。
その際、
#!/usr/bin/env python
import sys
import os
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, os.path.join(base_dir, "lib"))
sys.path.insert(0, base_dir)
import pikzie
sys.exit(pikzie.Tester().run())
をコピー&ペーストしました。
その後、
% test/run-test.py
を実行しました。
-bash: test/run-test.py: Permission denied
と表示され、実行ができませんでした。
README.jaの「使い方」の項目に
「run-test.pyを実行権限のある状態にしてからテストを実行してください」
という内容のことを、書いていただけると、実行がスムーズにいくと思います。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.