code: def test_from_string(self) -> None:
      # Name
      c = bcu.NamedColor.from_string("blue")
      assert c.name == "blue"
  
      # '#rrggbb'
      c = bcu.NamedColor.from_string("#A3B20F")
      assert (c.r, c.g, c.b, c.a) == (163, 178, 15, 1.0)
      c = bcu.NamedColor.from_string("#a3b20f")
      assert (c.r, c.g, c.b, c.a) == (163, 178, 15, 1.0)
  
      # '#rrggbbaa'
      c = bcu.NamedColor.from_string("#A3B20FC0")
      assert (c.r, c.g, c.b, c.a) == (163, 178, 15, 192 / 255.0)
      c = bcu.NamedColor.from_string("#a3b20fc0")
      assert (c.r, c.g, c.b, c.a) == (163, 178, 15, 192 / 255.0)
  
      # '#rgb'
      c = bcu.NamedColor.from_string("#7A3")
      assert (c.r, c.g, c.b, c.a) == (119, 170, 51, 1.0)
      c = bcu.NamedColor.from_string("#7a3")
      assert (c.r, c.g, c.b, c.a) == (119, 170, 51, 1.0)
  
      # '#rgba'
      c = bcu.NamedColor.from_string("#7A3B")
      assert (c.r, c.g, c.b, c.a) == (119, 170, 51, 187 / 255.0)
      c = bcu.NamedColor.from_string("#7a3b")
      assert (c.r, c.g, c.b, c.a) == (119, 170, 51, 187 / 255.0)
  
      # Invalid name
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("bluey")
  
      # Invalid hex string
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#1")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#12")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#12345")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#1234567")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string("#123456789")
      with pytest.raises(ValueError):
          bcu.NamedColor.from_string(" #abc")
  
file_path: bokeh/tests/unit/bokeh/colors/test_util__colors.py
imports: from __future__ import annotations
  import pytest
  from bokeh.colors import named
  import bokeh.colors.util
label_desc: Use image node_id 5 for calling the Test_NamedColor obj's underlying member method code with example usage: obj.test_from_string() without return types