Skip to content

Instantly share code, notes, and snippets.

View nicoddemus's full-sized avatar

Bruno Oliveira nicoddemus

View GitHub Profile
@nicoddemus
nicoddemus / conf.yaml
Created March 4, 2017 18:33
Configuration for conda-mirror while testing it a little
blacklist:
- name: "*"
- license: "*agpl*"
- license: None
- license: ""
- build: "*py34*"
- build: "*py36*"
whitelist:
- build: "*py27*"
@nicoddemus
nicoddemus / conftest.py
Created February 24, 2017 21:03
pytest plugin that shows environment variables when the build fails
def pytest_terminal_summary(terminalreporter, exitstatus):
import os
if exitstatus != 0 and 'JENKINS_URL' in os.environ:
markup = {'yellow': True, 'bold': True}
terminalreporter.write_sep("=", "ENVIRONMENT", **markup)
for k, v in sorted(os.environ.items()):
if k:
terminalreporter.write_line('%r: %r' % (k, v), **markup)
try:
os.remove(filename)
except PermissionError as e:
print('THIS PID', os.getpid())
import psutil
for proc in psutil.process_iter():
try:
files = proc.open_files()
except psutil.AccessDenied:
continue
@nicoddemus
nicoddemus / apply_dates.py
Created December 5, 2016 19:22
Reads dates from git and updates CHANGELOG entries From pytest-dev/pytest#721
from __future__ import absolute_import, division, print_function, unicode_literals
import re
import subprocess
with open('CHANGELOG.rst') as f:
changelog_lines = f.readlines()
output = subprocess.check_output('git log --tags --simplify-by-decoration --pretty="format:%ci %d"', shell=True)
tags_and_dates = {}
$ unzip -l library.zip
Archive: library.zip
Length Date Time Name
--------- ---------- ----- ----
0 2016-11-30 08:21 funcsigs/
0 2016-11-30 08:21 funcsigs-1.0.2.dist-info/
13297 2016-11-30 08:21 funcsigs-1.0.2.dist-info/DESCRIPTION.rst
4 2016-11-30 08:21 funcsigs-1.0.2.dist-info/INSTALLER
14420 2016-11-30 08:21 funcsigs-1.0.2.dist-info/METADATA
1294 2016-11-30 08:21 funcsigs-1.0.2.dist-info/metadata.json
@nicoddemus
nicoddemus / generate_tests_tree.py
Created November 22, 2016 12:44
Generates dummy test tree
"""
Creates a dummy tree with test files, with or without conftest.py files.
Usage:
generate_tests_tree.py 4 6 10 0
Generates a tree 4 levels deep, 6 folders per level and 10 test files each, without any conftest.py files. Each
test file contains 10 dummy tests.
"""
=========================== pytest-warning summary ============================
WW0 in testing\acceptance_test.py:629 the following warning was recorded:
..\..\..\..\..\..\..\..\..\pytest\.tox\py35\lib\site-packages\_pytest\vendored_packages\pluggy.py:250: PendingDeprecationWarning: generator 'pytest_pycollect_makeitem' raised StopIteration
wrap_controller.send(call_outcome)
WW0 in testing\deprecated_test.py:62 the following warning was recorded:
.tox\py35\lib\site-packages\_pytest\recwarn.py:65: DeprecationWarning: use of getfuncargvalue is deprecated, use getfixturevalue
old_warn(message, category, *args, **kwargs)
WW0 in testing\test_collection.py:350 the following warning was recorded:
from __future__ import absolute_import, division, print_function, unicode_literals
from functools import partial
class Hooks:
def pytest_about_to_timeout(self, config):
pass
@nicoddemus
nicoddemus / bld.bat
Last active July 8, 2016 12:33
pytest-2.9.1 recipe
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
:: Add more build steps here, if they are necessary.
:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.
@nicoddemus
nicoddemus / test_server.py
Created July 7, 2016 20:08
FTPServer fixture example
import re
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
import pytest
@pytest.yield_fixture
def ftp_server(tmpdir, request):
authorizer = DummyAuthorizer()