Skip to content

Package upgrade #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, 3.11] # List of Python versions to test against

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
update-environment: false

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Run Tox
run: tox

test_python_2:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Build
run: docker build -t backtrace-python .

- name: Run Docker Container
run: docker run --rm backtrace-python
61 changes: 59 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
*.egg-info
test_all
build/
# Byte-compiled files
*.pyc
*.pyo
*.pyd
__pycache__/

# Distribution / packaging
*.egg
*.egg-info/
dist/
build/
.eggs/
*.egg-info/
*.manifest
*.spec

# Installation directories
pip-log.txt
pip-delete-this-directory.txt

# pytest
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# pyenv
.python-version

# virtualenv
venv/
ENV/
env/
.venv/
env.bak/
venv.bak/

# tox
.tox/
nox/
coverage-report/

# IDEs and editors
.vscode/
.idea/
*.swp
*.swo

# macOS
.DS_Store

# Windows
Thumbs.db
Desktop.ini
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:2.7-slim

WORKDIR /sdk
COPY . /sdk

RUN pip install --upgrade pip \
&& pip install pytest -r requirements.txt

CMD ["pytest"]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
six
simplejson==3.19.3
24 changes: 18 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
#!/usr/bin/env python

from setuptools import setup
from setuptools import find_packages, setup

import backtracepython

setup(
name='backtracepython',
version=backtracepython.version_string,
description='Backtrace error reporting tool for Python',
author='Andrew Kelley',
author_email='akelley@backtrace.io',
packages=['backtracepython'],
description='Backtrace.io error reporting tool for Python',
author='Backtrace.io',
author_email='team@backtrace.io',
packages=find_packages(),
test_suite="tests",
url='https://github.com/backtrace-labs/backtrace-python',
install_requires=[
'six',
'simplejson',
]
],
extras_require={
'test': ['pytest'],
},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
)
38 changes: 16 additions & 22 deletions tests/__init__.py → tests/test_basic_flow.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import simplejson as json
import os
import subprocess
import sys
import unittest

import simplejson as json

if sys.version_info.major >= 3:
from http.server import HTTPServer
from http.server import BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer
else:
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

tests_dir = os.path.dirname(os.path.realpath(__file__))
exe_dir = os.path.join(tests_dir, "exe")
Expand All @@ -32,16 +30,13 @@ def check_basic_report(obj):
assert obj['attributes']['a'] == 1
assert obj['attributes']['b'] == "bar"

def check_multi_file(obj):
if sys.version_info.major >= 3:
assert obj['classifiers'][0] == "JSONDecodeError"
assert obj['attributes']['error.message'] == "Expecting value: line 1 column 1 (char 0)"
elif obj['langVersion'].startswith("PyPy"):
def check_multi_file(obj):
if obj['langVersion'].startswith("PyPy"):
assert obj['classifiers'][0] == "ValueError"
assert obj['attributes']['error.message'] == "Error when decoding true at char 1"
else:
assert obj['classifiers'][0] == "ValueError"
assert obj['attributes']['error.message'] == "No JSON object could be decoded"
assert obj['classifiers'][0] == "JSONDecodeError"
assert obj['attributes']['error.message'] == "Expecting value: line 1 column 1 (char 0)"

fault_stack = obj['threads'][obj['mainThread']]['stack']
source_code_id = fault_stack[-1]['sourceCode']
Expand Down Expand Up @@ -97,15 +92,14 @@ def log_message(self, format, *args):
httpd.server_close()


class TestErrorReports(unittest.TestCase):
def test_basic_report(self):
run_one_test(check_basic_report, "simple_report.py")
def test_basic_report():
run_one_test(check_basic_report, "simple_report.py")

def test_multi_file(self):
run_one_test(check_multi_file, "multi_file.py")
def test_multi_file():
run_one_test(check_multi_file, "multi_file.py")

def test_send_report(self):
run_one_test(check_send_report, "send_report.py")
def test_send_report():
run_one_test(check_send_report, "send_report.py")

def test_threads(self):
run_one_test(check_threads, "threads.py")
def test_threads():
run_one_test(check_threads, "threads.py")
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist = py27, py37, py38, py39, py310
skipsdist = True

[testenv]
deps =
-rrequirements.txt
pytest
commands =
pytest
Loading