I'm fairly green with python testing, so this might be something I'm doing wrong..
When I run my tests, the test runners works fine and coverage too.. but between the two I get an assertion error:
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 9, in <module>
load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')()
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main
status = CoverageScript().command_line(argv)
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line
self.coverage.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop
self.collector.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop
assert self._collectors[-1] is self
AssertionError
To make thing more difficult, I'm trying to test a command line utility. Which means I had to tell coverage to cover subprocess calls.
I think I got this part working since coverage is now reporting a % of cover for the script that is being run. But since I got coverage working I can't get rid of the AssertionError.
Some help understanding what's wrong would be really appreciated. All my code is available on github:
repo
setup.py
run_tests
subprocess call
Quick run:
cd /tmp/ && git clone git://github.com/h3/django-duke-client.git
cd django-duke-client && chmod a+x run_tests && ./run_tests
Thanks
Update
I've run the test on a different computer and I got the same AssertionError .. Plus a new TypeError. Again the tests runs correctly and coverage also seems to work properly even with those errors..
...
Ran 9 tests in 1.324s
OK
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 9, in <module>
load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')()
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main
status = CoverageScript().command_line(argv)
File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line
self.coverage.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop
self.collector.stop()
File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop
assert self._collectors[-1] is self
AssertionError
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Name Stmts Miss Branch BrPart Cover Missing
------------------------------------------------------------------------------
dukeclient/__init__ 53 53 2 0 4% 1-93
dukeclient/commands/__init__ 41 33 6 2 26% 1-9, 12, 14-15, 17, 24-28, 34-43, 46-63
...
Regarding the NoneType is not callable error, please find below some elements that may help you.
In your module plugintest.py from nose-1.1.2-py2.7.egg/nose/plugins/, line 174, one can read the following line :
from multiprocessing import Manager
That leads the multiprocessing.util package to be imported, and with it an exit function to be registered :
atexit.register(_exit_function)
The problem seems to be that multiprocessing.util which is loaded in plugintest is then unloaded before the _exit_function gets called, and it's function definitions by the way.
Thus, if you import it in your setup.py file :
from multiprocessing import util
The error disappear.
By the way, I had to comment some parts in the tests that were failing or change some lines of code :
the -m command does not seems to be valid ;
I had to rename duke_conf.yml to duke_conf.yml ;
the tests that checks if README.rst and LICENSE files exists are failing (don't had the time to check why) ;
Hope it helps,
Related
I have a Python Code to conduct an experiment. To ensure that the Code is working smoothly I wanted to run a trial round via 'otree devserver', but I always get an AttributeError message and I am stuck here. Can anyone help me out?
I have downloaded the Code from GitHub and downloaded all required packages. I am using macOS, otree-5.10.2 and django-4.1.7. Here is my full traceback / error message:
Traceback (most recent call last): File
"/Users/.otreevenv/bin/otree", line 8, in
sys.exit(execute_from_command_line()) File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
108, in execute_from_command_line
setup() File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
132, in setup
from otree import settings File "/Users/.otreevenv/lib/python3.10/site-packages/otree/settings.py",
line 50, in
OTREE_APPS = get_OTREE_APPS(settings.SESSION_CONFIGS) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 94, in __getattr__
val = getattr(_wrapped, name) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 270, in __getattr__
return getattr(self.default_settings, name) AttributeError: module 'django.conf.global_settings' has no attribute 'SESSION_CONFIGS'. Did
you mean: 'SESSION_ENGINE'?
I'm using this link as reference (https://medium.com/angular-in-depth/how-to-build-v8-on-windows-and-not-go-mad-6347c69aacd4) to build v8 but i think its out of date or i'm doing something wrong.
I can't run this (ninja -C out.gn/x64.release) command because its showing this error constantly
ninja: error: loading 'build.ninja': The system cannot find the file specified.
ninja: Entering directory `out.gn\foo
also im getting this error too
D:\v8_dev\v8Engine\v8>gn args out.gn\foo
Waiting for editor on "D:\v8_dev\v8Engine\v8\out.gn\foo\args.gn"...
Generating files...
Traceback (most recent call last):
File "D:/v8_dev/v8Engine/v8/build/vs_toolchain.py", line 561, in <module>
sys.exit(main())
File "D:/v8_dev/v8Engine/v8/build/vs_toolchain.py", line 557, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "D:/v8_dev/v8Engine/v8/build/vs_toolchain.py", line 371, in CopyDlls
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
File "D:/v8_dev/v8Engine/v8/build/vs_toolchain.py", line 346, in _CopyRuntime
suffix)
File "D:/v8_dev/v8Engine/v8/build/vs_toolchain.py", line 284, in _CopyUCRTRuntime
assert len(ucrt_files) > 0
AssertionError
ERROR at //build/toolchain/win/BUILD.gn:49:3: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py",
^----------
Current dir: D:/v8_dev/v8Engine/v8/out.gn/foo/
Command: D:/v8_dev/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe D:/v8_dev/v8Engine/v8/build/vs_toolchain.py copy_dlls D:/v8_dev/v8Engine/v8/out.gn/foo Release x64
Returned 1.
See //BUILD.gn:905:1: which caused the file to be included.
action("postmortem-metadata") {
^------------------------------
Ultimately i want it to work like as its shown in the embedded picture
if you are looking for the solution then follow this link (https://github.com/pmed/v8-nuget) for visual studio users, its working really well without all the hassle.
I am trying to invoke a C-program, named “drule.c”, from within my Python-program “drulewrapper.py”. I am trying to use "subprocess" but cannot get it to work.
1) I compile “drule.c” on the Mac’s terminal and all works okay:
$ gcc -o drule drule c
$ ./drule D11
>P>Q>RQ
Fyi, the input -- “D11” -- are axioms in predicate logic; the output -- “>P>Q>RQ” -- is the theorem that is proven and which I then want to process further in my Python program.
2) I write a short Python program (drulewrapper.py) and compile it:
From subprocess import call
def CheckString():
call(“./drule”, “D11”)
3) But when I run CheckString() I get errors:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
CheckString()
File "/Users/georgeszpiro/Dropbox/metamath/GApl/drulewrapper.py", line 3, in CheckString
call("./drule","D11")
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 609, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integerT
Can anybody help?
I'm having trouble debugging unit tests in pycharm. I can run them fine with my configuration but when I run the debugger I get the following error output:
Error
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 34, in testFailure
raise self._exception
ImportError: Failed to import test module: tests
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
__import__(name)
File "/Users/paymahn/solvvy/scheduler/tests/__init__.py", line 2, in
import tests.test_setup_script
File "/Users/paymahn/solvvy/scheduler/tests/test_setup_script.py", line 3, in
import setup
File "/Applications/PyCharm.app/Contents/helpers/pydev/setup.py", line 87, in
data_files.append(('pydevd_attach_to_process', [os.path.join('pydevd_attach_to_process', f) for f in os.listdir('pydevd_attach_to_process') if accept_file(f)]))
FileNotFoundError: [Errno 2] No such file or directory: 'pydevd_attach_to_process'
My directory structure is:
My unittest configuration is:
tests/test_setup_script.py looks like:
import unittest
import os
import setup # the path to this file is scheduler/setup.py. This import may be breaking things
class TestSetupScript(unittest.TestCase):
def test_load_db_connection_valid_yaml_file(self):
file_name = "valid-yaml.yml"
with open(file_name, 'w') as file:
file.write("""
test:
hello world
a = b
""")
yaml = setup.load_yaml_configuration(file_name)
# I want to debug the line above, hence no assertions here
What does pydevd_attach_to_process do and how can I make sure it's found during debugging? Is the problem not actually related to that file/directory being found?
Indeed, the failure occurs because the "import setup" in your code imports the setup module which is part of PyCharm's debugger runtime instead of your own setup module. The easiest fix to this is to rename your setup.py file to something else and to update the imports in your code accordingly.
I am trying to convert a JaCoCo coverage report to Cobertura format (since Shippable only supports Cobertura). This guy claims to have a tool to convert JaCoCo to Cobertura, however when running his script I get the following error:
Traceback (most recent call last):
File "cover2cover.py", line 151, in <module>
jacoco2cobertura(filename, source_root)
File "cover2cover.py", line 139, in jacoco2cobertura
convert_root(root, into, source_root)
File "cover2cover.py", line 127, in convert_root
packages.append(convert_package(package))
File "cover2cover.py", line 113, in convert_package
c_classes.append(convert_class(j_class, j_package))
File "cover2cover.py", line 100, in convert_class
c_methods.append(convert_method(j_method, j_method_lines))
File "cover2cover.py", line 85, in convert_method
convert_lines(j_lines, c_method)
File "cover2cover.py", line 33, in convert_lines
for jline in j_lines:
File "cover2cover.py", line 23, in method_lines
larger = list(int(jm.attrib['line']) for jm in jmethods if int(jm.attrib['line']) > start_line)
File "cover2cover.py", line 23, in <genexpr>
larger = list(int(jm.attrib['line']) for jm in jmethods if int(jm.attrib['line']) > start_line)
KeyError: 'line'
I know nothing about python, so any help would be appreciated.
I don't know python either, but I know that python 2 and python 3 have significant differences. Perhaps you ran into that?
I was able to run the script ok with this version:
$> python --version
Python 2.7.11
To ensure I got the script without any download or browser or line-ending type issues, I did clone the git repo:
$> git clone https://github.com/rix0rrr/cover2cover.git
Then the script ran first try on my jacoco XML file.