Skip to content

Commit

Permalink
test_runtime_exception: use monkeypatch
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoroze committed Mar 27, 2023
1 parent d0d6af6 commit 01578eb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/core/test_runtime_exception.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# Copyright 2020 Silicon Compiler Authors. All Rights Reserved.
import csv

import pytest

import siliconcompiler

def test_version():
@pytest.mark.quick
def test_version(monkeypatch):
chip = siliconcompiler.Chip('test')

org_find_func = siliconcompiler.Chip.find_function
# Replace find_function so we can throw an error
def find_function(modulename, funcname, moduletype=None, moduletask=None):
def find_function(self, modulename, funcname, moduletype=None, moduletask=None):
if funcname == 'parse_version':
def parse_version(text):
raise IndexError('This is an index error')
return parse_version
else:
return org_find_func(chip, modulename, funcname, moduletype=moduletype, moduletask=moduletask)
chip.find_function = find_function
return org_find_func(self, modulename, funcname, moduletype=moduletype, moduletask=moduletask)

monkeypatch.setattr(siliconcompiler.Chip, 'find_function', find_function)

chip.load_target('asic_demo')

Expand Down

0 comments on commit 01578eb

Please sign in to comment.