HazyResearch / fonduer

A knowledge base construction engine for richly formatted data
https://fonduer.readthedocs.io/
MIT License
409 stars 77 forks source link

Setup/teardown a database every unit test for better isolation #498

Closed HiromuHota closed 4 years ago

HiromuHota commented 4 years ago

Description of the problems or issues

Is your pull request related to a problem? Please describe.

This PR makes sure that unit tests are isolated from each other by creating and dropping a database every unit test, which can safety consolidate database names into a single one "fonduer_test".

This isolation is important for Fonduer as it dynamically creates different database tables through candidate_subclass() and mention_subclass(). As such, a test for #497 that I will write later would be much helped by this PR.

Does your pull request fix any issue.

N/A

Description of the proposed changes

This PR creates a fixture to setup/teardown a database.

Test plan

Existing tests would be good enough.

Checklist

codecov-commenter commented 4 years ago

Codecov Report

Merging #498 into master will decrease coverage by 0.09%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #498      +/-   ##
==========================================
- Coverage   85.85%   85.76%   -0.10%     
==========================================
  Files          88       88              
  Lines        4568     4567       -1     
  Branches      853      853              
==========================================
- Hits         3922     3917       -5     
- Misses        464      466       +2     
- Partials      182      184       +2     
Flag Coverage Δ
#unittests 85.76% <ø> (-0.10%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/fonduer/meta.py 94.44% <ø> (-2.82%) :arrow_down:
src/fonduer/candidates/models/candidate.py 76.27% <0.00%> (-3.39%) :arrow_down: