Q:

Do I have an unfound logic error in my unit test?

I am trying to see what I am missing, if anything, in a Python unittest. I was recently asked to write up some unittests. I am brand new to the IT field, and I've never done unittesting before. After working through several tutorials, I have a decent understanding when it comes to testing basic functions and ensuring things work, but can someone please take a look at the below and tell me if I'm missing anything logically?
This unittest is simply ensuring that a file will load. I'm getting no errors (which is a huge relief--I've worked on this for a good bit!), but I feel like I may be missing something. Here's a mockup, below:
My unittest passes, but I am just wondering if I am testing for all of the right things. I can't find any unittests that speak to potential logic errors on reading files.
import unittest, os, json

class TestLoadFile(unittest.TestCase):
    """Set up unittests for loading a file."""

    def setUp(self):
        data = {
            "name": "mike smith",
            "location": "atlanta, ga",
            "languages": {
                "first": "python",
                "second": "ruby",
                "third": "javascript"
            },
            "salary": "75000"
        }

        with open('test.json', 'w', encoding='utf-8') as f:
            json_info = json.dump(data, f, ensure_ascii=False, indent=4)

    def tearDown(self):
        os.unlink('test.json')

    def test_read_file(self):
        with open('test.json', 'r') as json_file:
            data = json.load(json_file)
            try:
              test_data_1 = data['name']
              test_data_2 = data['location']
              test_data_3 = data['languages']['second']
              test_data_4 = data['marital_status']

              # Assertions
              self.assertEqual(test_data_1, "mike smith")
              self.assertIn("atlanta", test_data_2)
              self.assertEqual(test_data_3, "ruby")
              self.assertRaises(KeyError, test_data_4)
            except:
              pass

if __name__ == '__main__': unittest.main()

Note this is just a mockup, obviously. I only included the try/except because it kept failing at the KeyError and I wasn't sure how to explicitly bypass that without wrapping the try/except. Is there anything that I'm not testing for that I should, particularly when it comes to a unittest involving reading a file? I am just trying to become a stronger code reader so that it helps me build better unittests.
Thanks, much!

A:

Usually Unit testing involves testing a small unit of your code to make sure it functions properly. However, here it seems like you're just testing if python is functioning correctly (Can write/read a file, and parse it into a dictionary). 
This test seems unneeded in my perspective because we know python works. We don't need to write additional unit test to make sure basic python functionality is working, because if it ever just randomly stops working, there are bigger problems.
However, if you wrote a custom method to parse a file and it needed to be in a particular format when after parsing, I would recommend testing that for sure!
mycode.py
----
def parse_config(path_to_config):
  if not os.path.exists(path_to_config):
     raise RuntimeException(f"Config file not found at path: {path_to_config}")

config = {
 'name': None,
 'location': None,
 'languages': None
}
with open(path_to_config, 'r') as json_file:
 config_data = json.load(json_file)

 for config_key in config.keys():
   if config_key in config_data:
     config[config_key] = config_data[key]

return config

test.py
---
def test_parse_config():

 with self.assertRaises(RuntimeException):
   parse_config('')

 config = parse_config('test.json')

 self.assertEqual(config['name'], 'mike smith')
 self.assertEqual(config['location'], 'atlanta')

 with self.assertRaises(KeyError):
   config['marital_status']

