Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pytest-cobra

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytest-cobra

PyTest plugin for testing Smart Contracts for Ethereum blockchain.

  • 1.0.4
  • PyPI
  • Socket score

Maintainers
2

PyTest-Cobra PyPI - Python Version

PyTest plugin for testing Smart Contracts for Ethereum blockchain.

Build Status PyPI Version GitHub License Github Date PyPI Wheel Donate with Ethereum

Dependency

This library requires the solc executable to be present.

Only versions >=0.4.2 are supported and tested though this library may work with other versions.

solc installation instructions

Install Solidity compiler (solc) using Node Package Manager(npm)

npm install -g solc

or for Ubuntu(Linux)

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

Quickstart

Installation

pip install pytest-cobra

Development

Clone the repository and then run

pip install -e . -r requirements.txt

Usage

Execute your test suite

Example MetaCoin picture

# MetaCoin Testing

# cobra is pytest fixture
def test_metacoin(cobra):

    # Getting Contract Factory by name
    metacoin = cobra.contract('MetaCoin')

    # Getting Contract Instance of MetaCoin
    metacoin = metacoin.deploy()

    assert metacoin.getBalance(cobra.accounts[0]) == 10000

Running test from Solidity file (.sol)

pytest --cobra MetaCoin.sol
Optional commands
Import path remappings

solc provides path aliasing allow you to have more reusable project configurations.

pytest --cobra MetaCoin.sol --import_remappings ["zeppeling=/my-zeppelin-checkout-folder"]
Allow paths
pytest --cobra MetaCoin.sol --allow_paths "/home/meheret,/user,/"

Running test from compiled Contracts Json file (.json)

Compile your contracts into a package (soon to be ethPM-compliant)

solc --combined-json abi,bin,bin-runtime contracts/ > MetaCoin.json

Testing Contracts.json

pytest --cobra MetaCoin.json

Running test from Yaml file (.yaml)

Comming Soon with Cobra Framework

Further help

PyTest

Go check out the PyTest.

Author ✒️

  • Meheret Tesfaye - Initial work - Cobra

License

This project is licensed under the MIT License - see the LICENSE file for details

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc