Repository: mciepluc/cocotb-coverage

Issue:
Access to `coverage_db['top'].detailed_coverage` field is failed.
`CoverItem` class contains `detailed_coverage` property and it can be accessed accordingly to spec. But trying to address it (for instance: `coverage_db['top'].detailed_coverage`) leads to fail. The cause of exception is using `append()` method for a dict in `CoverItem` code:
```        
coverage = {}
for child in self._children:
    coverage.append(child.detailed_coverage)
```


Comments:

Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..3faa610
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,60 @@
+name: Regression Tests
+
+on:
+  push:
+    branches:
+    - master
+  pull_request:
+    branches:
+    - master
+
+jobs:
+
+  lint-flake8:
+    runs-on: ubuntu-latest
+    name: flake8
+    strategy:
+      fail-fast: false
+      matrix:
+        python-version: [3.9]
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{matrix.python-version}}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{matrix.python-version}}
+
+    - name: flake8
+      continue-on-error: true
+      run: |
+        pip install flake8
+        flake8
+
+  tests:
+
+    name: Python ${{matrix.python-version}}
+    runs-on: ubuntu-20.04
+
+    strategy:
+      fail-fast: false
+      matrix:
+        python-version: ['3.7', '3.8', '3.9', '3.10']
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{matrix.python-version}}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{matrix.python-version}}
+
+    - name: Install Python testing dependencies
+      run: |
+        pip install tox tox-gh-actions
+
+    - name: Install Icarus Verilog
+      run: |
+        sudo apt install -y --no-install-recommends iverilog
+
+    - name: Test
+      run: |
+        tox
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index be1c526..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-sudo: required
-language: python
-dist: xenial
-cache:
-  directories:
-  - iverilog
-
-python:
-  - "3.7"
-
-before_install:
-  - sudo apt-get install gperf
-  - if [[ ! -e "./iverilog/README.txt" ]]; then rm -rf iverilog; git clone https://github.com/steveicarus/iverilog.git --depth=1 --branch v10_2; fi
-  - cd iverilog && autoconf && ./configure && make -j2 && sudo make install && cd ..
-  - pip install tox
-
-script:
-  - tox -e py3
diff --git a/README.md b/README.md
index 0a43173..48f55b2 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 Functional Coverage and Constrained Randomization Extensions for Cocotb
 
 [![Documentation Status](https://readthedocs.org/projects/cocotb-coverage/badge/?version=latest)](http://cocotb-coverage.readthedocs.org/en/latest/)
-[![Build Status](https://travis-ci.org/mciepluc/cocotb-coverage.svg?branch=master)](https://travis-ci.org/mciepluc/cocotb-coverage)
+[![Regression Tests](https://github.com/mciepluc/cocotb-coverage/actions/workflows/main.yml/badge.svg)](https://github.com/mciepluc/cocotb-coverage/actions/workflows/main.yml)
 [![PyPI](https://img.shields.io/pypi/dm/cocotb-coverage.svg?label=PyPI%20downloads)](https://pypi.org/project/cocotb-coverage/)
 
 This package allows you to use constrained randomization and functional coverage techniques known from CRV (constrained random verification) and MDV (metric-driven verification) methodologies, available in SystemVerilog or _e_. Such extensions enable the implementation of an advanced verification environment for complex projects.
diff --git a/cocotb_coverage/coverage.py b/cocotb_coverage/coverage.py
index 5c903cd..c9bdfe1 100644
--- a/cocotb_coverage/coverage.py
+++ b/cocotb_coverage/coverage.py
@@ -378,7 +378,7 @@ class CoverItem(object):
         """
         coverage = {}
         for child in self._children:
-            coverage.append(child.detailed_coverage)
+            coverage[child._name] = child.detailed_coverage
         return coverage
 
     @property
diff --git a/tox.ini b/tox.ini
index 46c9235..fd515c3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py3
+envlist = py37, py38, py39, py310
 
 [testenv]
 passenv =
@@ -10,8 +10,17 @@ whitelist_externals =
 
 deps =
     pytest
+    cocotb-bus
+    numpy
 
 commands =
     make -k -C tests
     make -C examples/fifo/tests
     make -C examples/pkt_switch/tests
+
+[gh-actions]
+python =
+    3.7: py37
+    3.8: py38
+    3.9: py39
+    3.10: py310
\ No newline at end of file


Test patch:
diff --git a/tests/test_coverage/coverage_test.py b/tests/test_coverage/coverage_test.py
index c884c9c..80b88ce 100644
--- a/tests/test_coverage/coverage_test.py
+++ b/tests/test_coverage/coverage_test.py
@@ -385,6 +385,33 @@ def test_bins_labels():
     assert coverage.coverage_db["top.t10.cross"].coverage == 4
 
 
+
+# accessing 'CoverItem.detailed_coverage' field
+def test_coveritem_detailed_coverage():
+    print("Running test_coveritem_detailed_coverage")
+
+    for i in range(10):
+        x = random.randint(0, 10)
+
+        @coverage.CoverPoint("top.t11.c1", vname="i", bins=list(range(10)))
+        @coverage.CoverPoint("top.t11.c2", vname="x", bins=list(range(10)))
+        def sample(i, x):
+            pass
+
+        sample(i, x)
+
+    detailed_coverage = coverage.coverage_db['top'].detailed_coverage
+    assert isinstance(detailed_coverage, dict)
+    assert isinstance(detailed_coverage['top.t11'], dict)
+    assert isinstance(detailed_coverage['top.t11'], dict)
+
+    detailed_coverage = coverage.coverage_db['top.t11'].detailed_coverage
+    assert isinstance(detailed_coverage, dict)
+    assert len(detailed_coverage) == 2
+    assert detailed_coverage['top.t11.c1'] is not None
+    assert detailed_coverage['top.t11.c2'] is not None
+
+    
 def test_tutorial_coverpoint_transition():
 
     addr_prev = collections.deque(4*[0], 4) # we would need up to 4 values in this example