Giter VIP home page Giter VIP logo

istant's Introduction

istant

security: bandit Code style: black

A Python package to check if an object is of a certain type in an instant.

Development

  • poetry install
  • poetry shell
  • pytest

Tech Stack

Packaging and Development

This package was created with Cookiecutter and the joaopalmeiro/cookiecutter-templates/python-pkg project template.

References

Notes

  • pyenv:
  • Vim:
    • Learning tools:
    • Two basic modes:
      • insert mode (i): to write text (like in a text editor).
      • normal mode (Esc): to navigate and manipulate text.
    • Basic movement: h (←), j (↓), k (↑), and l (→).
    • Word movement:
      • w: start of the next word.
      • e: end of the word.
      • b: beginning of the word.
      • These keys can be combined with a number (number powered movement). 3w is the same as pressing w 3x, for example.
    • Insert text repeatedly: 30 + i + - + Esc to insert - 30x, for example.
    • Find a character:
      • f: next occurrence of a character.
      • F: previous occurrence of a character.
      • fo to find the next o, for example.
      • These keys can also be combined with numbers.
    • Go to matching parentheses: %.
    • Go to start/end of line: 0/$.
    • Find word under cursor:
      • *: next occurrence.
      • #: previous occurrence.
    • Go to beginning/end of file: gg/G. G can be combined with a number too.
    • Search:
      • /<text>.
      • n: next occurrence.
      • N: previous occurrence.
    • Insert new line:
      • o: below the current line.
      • O: above the current line.
      • The editor is set to insert mode.
    • Remove a character:
      • x: under the cursor.
      • X: to the left of the cursor.
    • Replace a character:
      • r.
      • Under the cursor, without switching to insert mode.
    • Delete:
      • d.
      • It can be combined with numbers and movement keys (dw and d2e, for example).
      • It copies the content. Content can be pasted with p.
    • Repeat the previous command: ..
    • Visual mode:
      • v.
      • To select text with the movement keys first and then apply a command.
    • Exiting:
      • :w: save.
      • :q: quit.
      • :q!: quit without saving.
    • Editing:
      • u: undo.
      • Ctrl + r: redo.
    • Vim.gitignore file.

VIM and Python – A Match Made in Heaven

Source.

  • .vimrc file.
  • vim --version.
  • *nix or Unix-like systems.
  • Check the Python version used in Vim: :python import sys; print(sys.version).
  • Extensions or bundles or plugins.
  • Vundle:
    • pip for Vim/Vim plugin manager.
    • git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim.
    • Extensions can be managed from the .vimrc file (touch ~/.vimrc) + :PluginInstall.
  • Split layouts:
    • :sp <filename>: vertical split.
    • :vs <filename>: horizontal split.
  • vscode-viml-syntax (VS Code extension).
  • Buffers:
    • Think of a buffer as a recently opened file.
    • :b <buffer name or number>: switch to an open buffer.
    • :ls: list all buffers.
  • Extensions:

Effective Python Testing With Pytest

Source.

  • poetry add -D pytest.
  • Arrange (set up)-Act-Assert model.
  • pytest allows you to use Python's assert directly.
  • Test double: an object that stands in for another object during a test (source), such as mocks, for example.
  • Fixtures (@pytest.fixture decorator + conftest.py file):
    • Functions that create data/test doubles or initialize some system state for the test suite.
    • They are appropriate to be used across multiple tests.
    • They are used as arguments (explicit dependency declarations).
    • They are modular, so they can depend on other fixtures.
  • Test filtering:
    • Name-based filtering (-k).
    • Directory scoping.
    • Test categorization (-m <name> or -m "not <name>"). pytest allows you to create marks (custom labels) for any test.
  • Test parameterization.
  • Plugin-based architecture.
  • monkeypatch fixture (+ @pytest.fixture(autouse=True) in the conftest.py file): to safely patch and mock functionality in tests, allowing to set/delete an attribute, dictionary item, or environment variable, for example (requests.get(), for example).
  • Marks (@pytest.mark.<name>):
    • It is possible to register marks in the pytest.ini file (or in the pyproject.toml file). This can be combined with the --strict-markers flag to ensure that all marks in the tests are registered in the pytest configuration. On the other hand, addopts = --strict-markers can be added to the pytest.ini file.
    • Run pytest --markers to check the list of marks.
    • skip: to skip a test.
    • skipif: to skip a test if the expression passed to it evaluates to True.
    • xfail: a test is expected to fail.
    • parametrize. The first argument is a comma-delimited string of parameter names. The second argument is a list of either tuples or single values.
  • --durations flag:
    • To include a duration report in the results.
    • --durations=3 to report the slowest 3 tests, for example.
  • Plugins:

istant's People

Contributors

joaopalmeiro avatar

Watchers

 avatar

istant's Issues

Add pytest and first unit tests

References:

Example:

@pytest.mark.parametrize("palindrome", [
    "",
    "a",
    "Bob",
    "Never odd or even",
    "Do geese see God?",
])
def test_is_palindrome(palindrome):
    assert is_palindrome(palindrome)

@pytest.mark.parametrize("non_palindrome", [
    "abc",
    "abab",
])
def test_is_palindrome_not_palindrome(non_palindrome):
    assert not is_palindrome(non_palindrome)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.