Unable to run py.test for the default `populus init` project
bonedaddy opened this issue · comments
Im following tutorial and after running populus init
I ran populus compile
. I'm trying to get the default tests to run but get the following error
py.test tests/ --populus-project $(pwd)
=============================================== test session starts ================================================
platform linux -- Python 3.6.4, pytest-3.2.5, py-1.5.2, pluggy-0.4.0
rootdir: /home/solidity/Documents/testing, inifile:
plugins: xdist-1.18.1, hypothesis-3.44.14, populus-2.2.0
collected 2 itemstests/test_greeter.py EE
====================================================== ERRORS ======================================================
__________________________________________ ERROR at setup of test_greeter __________________________________________request = <SubRequest 'project' for <Function 'test_greeter'>>
pytestconfig = <_pytest.config.Config object at 0x7fd997d59b00>@pytest.fixture() def project(request, pytestconfig): project_dir = get_populus_option( cmdline_option="--populus-project", ini_option="populus_project", environ_var="PYTEST_POPULUS_PROJECT", pytestconfig=pytestconfig, default=os.getcwd(), ) if not os.path.exists(get_json_config_file_path(project_dir)): raise FileNotFoundError( "No populus project found for testing in {project_dir}".format(
project_dir=project_dir
) )
E FileNotFoundError: No populus project found for testing in /home/solidity/Documents/testing
/usr/lib/python3.6/site-packages/populus-2.2.0-py3.6.egg/populus/plugin.py:60: FileNotFoundError
______________________________________ ERROR at setup of test_custom_greeting ______________________________________request = <SubRequest 'project' for <Function 'test_custom_greeting'>>
pytestconfig = <_pytest.config.Config object at 0x7fd997d59b00>@pytest.fixture() def project(request, pytestconfig): project_dir = get_populus_option( cmdline_option="--populus-project", ini_option="populus_project", environ_var="PYTEST_POPULUS_PROJECT", pytestconfig=pytestconfig, default=os.getcwd(), ) if not os.path.exists(get_json_config_file_path(project_dir)): raise FileNotFoundError( "No populus project found for testing in {project_dir}".format(
project_dir=project_dir
) )
E FileNotFoundError: No populus project found for testing in /home/solidity/Documents/testing
/usr/lib/python3.6/site-packages/populus-2.2.0-py3.6.egg/populus/plugin.py:60: FileNotFoundError
============================================= 2 error in 0.04 seconds ==============================================
[
Did you ever find the fix for this? I just ran into the same error
I'd like to use this, however, if its not going to work, I'll just go back to truffle... lol
No unfortunately I did not. Ive also run into breaking bugs with this and web3py which is a shame all the Python tools for Ethereum are quite honestly garbage
And yeah, I have too. What problems are you having with web3.py? I’ve fixed most of mine so far, so maybe I can help you?
Also, when you copy the json file, make sure you read the notes, as the json has to be at the root project level.
@harpangell7 I was able to get the tests running by following the instructions in issue #414 However I get the following error now
==================================================================================== test session starts =====================================================================================
platform linux -- Python 3.6.3, pytest-3.2.5, py-1.5.2, pluggy-0.4.0
rootdir: /home/solidity/testing/tests, inifile:
plugins: xdist-1.18.1, hypothesis-3.44.16, populus-2.2.0
collected 2 items
test_greeter.py FF
========================================================================================== FAILURES ==========================================================================================
________________________________________________________________________________________ test_greeter ________________________________________________________________________________________
chain = <populus.chain.tester.TesterChain object at 0x7f6446942e10>
def test_greeter(chain):
> greeter, _ = chain.provider.get_or_deploy_contract('Greeter')
test_greeter.py:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:146: in get_or_deploy_contract
deploy_kwargs=deploy_kwargs,
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:115: in deploy_contract
contract_data = self.get_contract_data(contract_identifier)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <populus.contracts.provider.Provider object at 0x7f643e5c4eb8>, contract_identifier = 'Greeter'
def get_contract_data(self, contract_identifier):
"""
Returns a dictionary containing the compiler output for the given
contract identifier.
"""
for backend in self.provider_backends.values():
try:
return backend.get_contract_data(contract_identifier)
except UnknownContract:
continue
else:
raise UnknownContract(
"No contracts found for the contract identifier '{0}'".format(
> contract_identifier,
)
)
E populus.contracts.exceptions.UnknownContract: No contracts found for the contract identifier 'Greeter'
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:174: UnknownContract
____________________________________________________________________________________ test_custom_greeting ____________________________________________________________________________________
chain = <populus.chain.tester.TesterChain object at 0x7f643e630160>
def test_custom_greeting(chain):
> greeter, _ = chain.provider.get_or_deploy_contract('Greeter')
test_greeter.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:146: in get_or_deploy_contract
deploy_kwargs=deploy_kwargs,
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:115: in deploy_contract
contract_data = self.get_contract_data(contract_identifier)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <populus.contracts.provider.Provider object at 0x7f643e642b38>, contract_identifier = 'Greeter'
def get_contract_data(self, contract_identifier):
"""
Returns a dictionary containing the compiler output for the given
contract identifier.
"""
for backend in self.provider_backends.values():
try:
return backend.get_contract_data(contract_identifier)
except UnknownContract:
continue
else:
raise UnknownContract(
"No contracts found for the contract identifier '{0}'".format(
> contract_identifier,
)
)
E populus.contracts.exceptions.UnknownContract: No contracts found for the contract identifier 'Greeter'
/usr/local/lib/python3.6/dist-packages/populus-2.2.0-py3.6.egg/populus/contracts/provider.py:174: UnknownContract
================================================================================== 2 failed in 0.35 seconds ==================================================================================
Did you get this fixed?
Is there a fix for this?
No never found a fix
Likely duplicate of #414 (EDIT: ah, has been mentioned).
I ran across the error reported at the beginning of this issue i.e. FileNotFoundError: No populus project found for testing in ..
After applying the "fix" from #414 - the error went away.
I did not encounter any other error, and the tests passed.
Populus Version: 2.2.0
OS: osx
Problem:
FileNotFoundError: No populus project found for testing in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/populus/plugin.py:60
Solution:
when we run $ populus init command it will Wrote default populus configuration file at this location /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/populus/assets/defaults.v8.config.json
copy defaults.v8.config.json file and paste it on your project and rename defaults.v8.config.json to project.json file. This solution solved the issue for me
https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts > populus
Closing since I don't use this library anymore