treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
182 stars 18 forks source link

mocks #74

Closed alex-treebeard closed 2 years ago

alex-treebeard commented 2 years ago

Enable mocking variables by allowing metadata which causes nbmake to overwrite variables after a cell finishes.

issue: https://github.com/treebeardtech/nbmake/issues/72

example from unit test:

  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "nbmake": {
     "mock": {
      "x": 2,
      "y": "fish",
      "z": {
       "x": 42
      }
     }
    }
   },
   "outputs": [],
   "source": [
    "x = 5\n",
    "y = 'y'"
   ]
  },
codecov[bot] commented 2 years ago

Codecov Report

Merging #74 (c85213c) into main (966edac) will decrease coverage by 0.74%. The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
- Coverage   92.46%   91.71%   -0.75%     
==========================================
  Files           4        4              
  Lines         146      157      +11     
==========================================
+ Hits          135      144       +9     
- Misses         11       13       +2     
Impacted Files Coverage Δ
src/nbmake/nb_run.py 92.10% <83.33%> (-1.75%) :arrow_down: