Explanation:
__enter__ is giving None as an output, since there is no return, therefore it would directly trigger __exit__ since None has no attribute name, ex:
>>> None.name
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    None.__name__
AttributeError: 'NoneType' object has no attribute 'name'
>>> 
If you set it to call __class__.__name__ (None objects have that attribute, which gives NoneType), you could find the problem easily:
class Test:
    def __init__(self, name):
        self.name = name
    def __enter__(self):
        print(f'entering {self.name}')
    def __exit__(self, exctype, excinst, exctb) -> bool:
        print(f'exiting {self.name}')
        return True
with Test('first') as test:
    print(f'in {test.__class__.__name__}')
test = Test('second')
with test:
    print(f'in {test.__class__.__name__}')
Output:
entering first
in NoneType
exiting first
entering second
in Test
exiting second
As you can see, it says in NoneType, not returning any value is the reason to this. In a lot of cases, __enter__ doesn't need to return, but in this case the Test class needs it to return.
Solution:
The solution would be to keep the Test instance, so that it calls the name of a returned self after the context manager __enter__ result. So far the __enter__ results None, therefore None.name attribute doesn't exist. So if you return self, test.name attribute would exist.
The solution would be to return self in the __enter__ magic method implementation:
    ...
    def __enter__(self):
        print(f'entering {self.name}')
        return self
    ...
Full code:
class Test:
    def __init__(self, name):
        self.name = name
    def __enter__(self):
        print(f'entering {self.name}')
        return self
    def __exit__(self, exctype, excinst, exctb) -> bool:
        print(f'exiting {self.name}')
        return True
with Test('first') as test:
    print(f'in {test.name}')
test = Test('second')
with test:
    print(f'in {test.name}')
Output:
entering first
in first
exiting first
entering second
in second
exiting second
The extra info I gave that the other answers didn't give is a more concrete proof of the __enter__ method implementation giving None. I showed an example as well of it.