Skip to content

Commit

Permalink
First running tests with tox
Browse files Browse the repository at this point in the history
  • Loading branch information
jhillairet committed Mar 24, 2024
1 parent 03172db commit 1dc7ea8
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/testing.yml
@@ -0,0 +1,29 @@
name: Code testing

on: [push, pull_request]

jobs:
Tests:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
# run the tests located in skrf/
- name: Test the code, tutorials and examples
if: ${{ always() }}
run: |
tox
22 changes: 22 additions & 0 deletions tox.ini
@@ -0,0 +1,22 @@
# running 'tox' will run the tests located in west_ic_antenna/
# running 'tox -- --nbval-lax' will also run all the notebooks located in doc/
[tox]
isolated_build = True
envlist = py{37, 38, 39, 310, 311, 312}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312

# This is the default testsetup with all dependencies installed
[testenv]
deps =
pytest
commands =
python -m pytest

46 changes: 46 additions & 0 deletions west_ic_antenna/test/test_antenna.py
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
import pytest
import skrf as rf
import os

from west_ic_antenna.antenna import (
WestIcrhAntenna,
DEFAULT_FRONT_FACE,
S_PARAMS_DIR,
DEFAULT_BRIDGE,
DEFAULT_IMPEDANCE_TRANSFORMER,
DEFAULT_SERVICE_STUB,
)

# Useful definitions
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
DATA_DIR = os.path.join(TEST_DIR, '../data')

@pytest.fixture
def antenna_default_arg():
return WestIcrhAntenna()

# Constructor Tests
def test_constructor_default(antenna_default_arg):
"""Test creation of Antenna instance"""
assert isinstance(antenna_default_arg, WestIcrhAntenna)

def test_setup_constructor_frequency():
freq = rf.Frequency(30, 60, npoints=10, unit='MHz')
_ant = WestIcrhAntenna(frequency=freq)
assert isinstance(_ant, WestIcrhAntenna)

def test_setup_constructor_capa():
Cs = [20, 30, 40, 50]
_ant = WestIcrhAntenna(Cs=Cs)
assert isinstance(_ant, WestIcrhAntenna)

def test_setup_constructor_frontface_filename():
_ant = WestIcrhAntenna(front_face=DEFAULT_FRONT_FACE)
assert isinstance(_ant, WestIcrhAntenna)

def test_setup_constructor_frontface_network():
ntw = rf.Network(DEFAULT_FRONT_FACE)
_ant = WestIcrhAntenna(front_face=ntw)
assert isinstance(_ant, WestIcrhAntenna)

0 comments on commit 1dc7ea8

Please sign in to comment.