Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[report]
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if __name__ == .__main__.:
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ matrix:
- python: '3.7'
env: NOXSESSION="docs"
dist: xenial
- python: '3.8-dev'
env: NOXSESSION="tests-3.8"
dist: xenial

install:
# commands for linux
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ prune gdbgui/__pycache__

exclude mypy.ini
exclude .eslintrc.json
exclude .coveragerc
exclude .flake8
exclude .prettierrc.js
exclude jest.config.js
Expand Down
24 changes: 23 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,33 @@
@nox.session(python=python)
def tests(session):
session.install(".")
session.run("python", "-m", "unittest", "discover")
tests = session.posargs or ["tests"]
session.install(".", "pytest", "pytest-cov")
tests = session.posargs or ["tests"]
session.run(
"pytest", "--cov=gdbgui", "--cov-config", ".coveragerc", "--cov-report=", *tests
)

session.run("yarn", "install", external=True)
session.run("yarn", "test", external=True)
session.run("yarn", "build", external=True)

session.notify("cover")


@nox.session
def cover(session):
"""Coverage analysis"""
session.install("coverage")
session.run(
"coverage",
"report",
"--show-missing",
"--omit=gdbgui/SSLify.py",
"--fail-under=30",
)
session.run("coverage", "erase")


@nox.session(python="3.7")
def lint(session):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
python_requires=">=3.6",
project_urls={
Expand Down
81 changes: 0 additions & 81 deletions tests/test_app.py

This file was deleted.

37 changes: 37 additions & 0 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from gdbgui import backend
from flask_socketio import send, SocketIO # type: ignore
import pytest # type: ignore


backend.setup_backend(testing=True)
socketio = backend.socketio


def test_connect():
app = backend.app
socketio = SocketIO()

@socketio.on("connect")
def on_connect():
send({"connected": "foo"}, json=True)

socketio.init_app(app, cookie="foo")
client = socketio.test_client(app)
received = client.get_received()
assert len(received) == 1
assert received[0]["args"] == {"connected": "foo"}


@pytest.fixture
def test_client():
return backend.app.test_client()


def test_load_main_page(test_client):
response = test_client.get("/")
assert response.status_code == 200
assert "<!DOCTYPE html>" in response.data.decode()


def test_same_port():
backend.setup_backend(testing=True)
22 changes: 22 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import gdbgui
import pytest # type: ignore
import sys


@pytest.mark.parametrize(
"test_argv, init_bin_args, gdb_args",
[
(["gdbgui"], [], []),
(["gdbgui", "--gdb-args", "mybin -myargs"], [], ["mybin", "-myargs"]),
(["gdbgui", "--args", "mybin", "-myargs"], ["mybin", "-myargs"], []),
],
)
def test_argument_parsing(monkeypatch, test_argv, init_bin_args, gdb_args):
def mock_setup_backend(*args, **kwargs):
pass

monkeypatch.setattr(gdbgui.backend, "setup_backend", mock_setup_backend)
monkeypatch.setattr(sys, "argv", test_argv)
gdbgui.backend.main()
assert gdbgui.backend.app.config.get("initial_binary_and_args") == init_bin_args
assert gdbgui.backend.app.config.get("gdb_args") == gdb_args